Skip to content

Instantly share code, notes, and snippets.

@NoahDragon
Last active February 3, 2016 21:51
Show Gist options
  • Save NoahDragon/fe0307015066c406c01a to your computer and use it in GitHub Desktop.
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.
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