How to use IsNullOrEmpty in VB.NET?
-
21-07-2021 - |
Frage
Why doesn't the following compile in VB.NET?
Dim strTest As String
If (strTest.IsNullOrEmpty) Then
MessageBox.Show("NULL OR EMPTY")
End if
Lösung
IsNullOrEmpty is 'shared' so you should use it that way:
If String.IsNullOrEmpty(strTest) Then
Andere Tipps
You can actually just compare to an empty string:
If strTest = "" Then
MessageBox.Show("NULL OR EMPTY")
End If
String.IsNullOrEmpty is a shared (or static, in C#) method.
Dim strTest As String
If (String.IsNullOrEmpty(strTest)) Then
MessageBox.Show("NULL OR EMPTY")
End if
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow