Hello - I had an issue that I have now corrected, but I'd like to understand why the original way I had this behaved as it did.
Original way:
When the above code executed, I expected the variable b to be null (Nothing), however, it contained zero (0).Code:Dim b As Byte? Dim s As String = " " ' s will either contain a blank space or a digit between 0 and 3 b = CType(if(s = " ", Nothing, s), Byte?)
The fix:
When the above code executed, b was Nothing as one would expect.Code:Dim b As Byte? Dim s As String = " " ' s will either contain a blank space or a digit between 0 and 3 b = If(s = " ", Nothing, CType(s, Byte?))
The question is why did the first example return 0 rather than Nothing?




Reply With Quote