Mega Code Archive

 
Categories / VB.Net Tutorial / Data Type
 

Assigning Nothing to a variable sets it to the default value for its declared type

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