如何在 VB.NET 中使用 IsNullOrEmpty?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13134534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:41:14 来源:igfitidea点击:
How to use IsNullOrEmpty in VB.NET?
提问by CJ7
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
回答by Tomq
IsNullOrEmpty is 'shared' so you should use it that way:
IsNullOrEmpty 是“共享的”,所以你应该这样使用它:
If String.IsNullOrEmpty(strTest) Then
回答by Rolf Bjarne Kvinge
You can actually just compare to an empty string:
您实际上可以与空字符串进行比较:
If strTest = "" Then
MessageBox.Show("NULL OR EMPTY")
End If
回答by moribvndvs
String.IsNullOrEmptyis 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

