Last active
February 3, 2016 21:51
-
-
Save NoahDragon/fe0307015066c406c01a to your computer and use it in GitHub Desktop.
VB.NET nullable integer assign nothing through If statement may result nothing=0 issue if another return variable is not nullable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Public Module Module1 | |
Public Sub Main() | |
Dim a as Integer? = Nothing | |
Dim b as Integer = 5 | |
Dim c as Integer? = 5 | |
a = If(1=1, nothing, b) | |
Console.WriteLine(a) ' 0 | |
a = Nothing | |
Console.WriteLine(a) ' nothing | |
a = If(1=1, nothing, c) | |
Console.WriteLine(a) ' nothing | |
End Sub | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment