How to use IsNullOrEmpty in VB.NET?

CJ7 picture CJ7 · Oct 30, 2012 · Viewed 94k times · Source

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

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

Answer

Tomq picture Tomq · Oct 30, 2012

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

If String.IsNullOrEmpty(strTest) Then