我有一个字符串数组,我循环遍历它们,但字符串可能是空的所以我正在尝试这个:
For Each Component As String In Components If Component IsNot String.Empty Then 'Work your magic End If Next
但是如果Component是一个空字符串,逻辑仍然会触发.我也试过了
If Component <> "" Then End If
结果相同.那我错过了什么?
解决方法
>确保列表的类型为字符串
>使用String.IsNullOrEmpty方法.
>使用String.IsNullOrEmpty方法.
Sub Main Dim foo As String foo = "Non-Empty string" If Not String.IsNullOrEmpty(foo) Then Console.WriteLine("Foo is not empty.") End If End Sub
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。