C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
VB.NET program that uses Is, IsNot operators
Module Module1
Sub Main()
Dim value As String = "cat"
' Check if it is NOT Nothing.
If value IsNot Nothing Then
Console.WriteLine(1)
End If
' Change to Nothing.
value = Nothing
' Check if it IS Nothing.
If value Is Nothing Then
Console.WriteLine(2)
End If
' This isn't reached.
If value IsNot Nothing Then
Console.WriteLine(3)
End If
End Sub
End Module
Output
1
2
Note: These are most commonly used with the Nothing constant. But any two references can be compared.
And: The result depends on the memory locations—not the object data the references point to.