Search code examples
.netvb.netstringisnullorempty

How to use IsNullOrEmpty in VB.NET?


Why doesn't the following compile in VB.NET?

Dim strTest As String
If (strTest.IsNullOrEmpty) Then
   MessageBox.Show("NULL OR EMPTY")
End if

Solution

  • IsNullOrEmpty is 'shared' so you should use it that way:

    If String.IsNullOrEmpty(strTest) Then