简体   繁体   English

如何在VB.NET中使用IsNullOrEmpty?

[英]How to use IsNullOrEmpty in VB.NET?

Why doesn't the following compile in VB.NET? 为什么以下不在VB.NET中编译?

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

IsNullOrEmpty是'共享'所以你应该这样使用它:

If String.IsNullOrEmpty(strTest) Then

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. String.IsNullOrEmpty是一个共享(或静态,在C#中)方法。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM