Assigning Nothing to a variable sets it to the default value for its declared type. : Nullable « Data Type « VB.Net Tutorial






Module Module1
    Public Structure testStruct
        Public name As String
        Public number As Short
    End Structure

    Sub Main()

        Dim ts As testStruct
        Dim i As Integer
        Dim b As Boolean

        ' The following statement sets ts.name to "" and ts.number to 0.
        ts = Nothing

        ' The following statements set i to 0 and b to False.
        i = Nothing
        b = Nothing

        Console.WriteLine("ts.name: " & ts.name)
        Console.WriteLine("ts.number: " & ts.number)
        Console.WriteLine("i: " & i)
        Console.WriteLine("b: " & b)

    End Sub

End Module








2.48.Nullable
2.48.1.Assigning Nothing to a variable sets it to the default value for its declared type.
2.48.2.Nullable(Of T).GetValueOrDefault methods.
2.48.3.If the variable is of a reference type, a value of Nothing is a null value.