VB.Net program to demonstrate the NullReferenceException
'Vb.Net program to demonstrate the NullReferenceException.
Module Module1
Class Sample
Public Sub SayHello()
Console.WriteLine("Hello World")
End Sub
End Class
Sub Main()
Try
Dim S As New Sample()
S = Nothing
S.SayHello()
Catch e As NullReferenceException
Console.WriteLine(e.Message)
End Try
End Sub
End Module
Object reference not set to an instance of an object.
Press any key to continue . . .
Table of Contents