Possible Duplicate:
Bug?? If you assign a value to a nullable integer via a ternary operator, it can't become null
While this question may seem like a duplicate of many, it is actually being asked for a specific reason. Take this code, for example:
Dim n As Integer? = If(True, Nothing, 1)
In that code, the ternary expression should be returning Nothing, but it's setting n to 0. If this were C#, I could say default(int?)
and it would work perfectly. Now it looks like I am going to have to ditch the ternary and use a regular If block, but I really want to use the ternary.
If Nothing were truly VB.NET's equivalent to C#'s default, how can you explain this behavior?