We all know that VB's
Dim o As Object = If(myBool, 5, ...)
The first answer I gave missed some points, but this should do it:
Dim o As Object = If(myBool, 5, DirectCast(Nullable.GetUnderlyingType(GetType(Integer)), Object))
This uses the fact that
Nullable.GetUnderlyingType will return a null reference if you pass it a type which isn't a nullable value type - which
Integer isn't. Other alternatives exist, such as
Type.GetElementType(), or perhaps
I've checked that this works with multiple different types for the second operand.
It's slightly annoying that you have to cast to
Object... I'm still working on alternatives for that...