How to use IsNullOrEmpty in VB.NET?

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

Dim strTest As String If (strTest.IsNullOrEmpty) Then MessageBox.Show("NULL OR EMPTY") End if 
+7
source share
3 answers

IsNullOrEmpty is "generic", so you should use it this way:

 If String.IsNullOrEmpty(strTest) Then 
+23
source

In fact, you can simply compare with an empty string:

 If strTest = "" Then MessageBox.Show("NULL OR EMPTY") End If 
+6
source

String.IsNullOrEmpty is a generic (or static, in C #) method.

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

All Articles