What is the equivalent of null in VB.NET

1 Answer

0 votes
' null in VB.NET is Nothing
' null = Nothing

Imports System

Public Class Test
    Public Shared Sub Main()
        Dim s As String = Nothing

        Console.WriteLine("s = " & s)

        If s = Nothing Then
            Console.WriteLine("Nothing")
        End If

        If String.IsNullOrEmpty(s) Then
            Console.WriteLine("Null Or Empty")
        End If
        
    End Sub
End Class



' run:
'
' s = 
' Nothing
' Null Or Empty
' 

 



answered Mar 8, 2021 by avibootz
edited May 21, 2024 by avibootz

Related questions

1 answer 78 views
1 answer 197 views
2 answers 188 views
1 answer 164 views
164 views asked Jun 25, 2022 by avibootz
1 answer 203 views
1 answer 224 views
...