vb.net 如何检查字符串是否在 Visual Basic 中的数组中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9038637/
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-09 15:54:15 来源:igfitidea点击:
How do I check to see if a string is within an array in Visual Basic?
提问by Matt Elhotiby
I am a PHP developer and not a Visual Basic person.
我是一名 PHP 开发人员,而不是 Visual Basic 人员。
I have an array:
我有一个数组:
Dim ShippingMethod() As String = {"Standard Shipping", "Ground EST"}
Dim Shipping as String = "Ground EST"
How do I do an if
statement that will check if the string Shipping
is in the ShippingMethod()
array?
如何执行if
检查字符串Shipping
是否在ShippingMethod()
数组中的语句?
回答by vcsjones
回答by rbassett
回答by codingg
Answer:
回答:
Dim things As String() = {"a", "b", "c"}
If things.Contains("a") Then
' do things
Else
' don't do things
End If