VB.NET , the equivalent of C # default, is a keyword Nothing. The code you wrote should compile just fine, as long as it Id.Valuereturns a value Integer.
The reason your updated sample is wrong is due to nature Nothing. In VB.NET, it Nothingis an empty value and it is converted to any type. Now, for the expression, the Ifcompiler must determine what the type of the return value should be, and he does this by considering the two arguments of the value.
Nothing , 1 Integer. Nothing Integer, Integer. , Nothing , Integer, Integer?.
- , , 1 Integer?.
Dim n As Integer? = If(True, Nothing, CType(1, Integer?))