你能在 Select Case 语句中使用 .Contains(string) 吗? [英] Can you use .Contains(string) with a Select Case Statement?
本文介绍了你能在 Select Case 语句中使用 .Contains(string) 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
无论如何我可以构建一个使用 Contains 函数的 Select 语句吗?像这样:
Is there anyway I can build a Select statement that uses the Contains function? Like this:
Select commentStr
Case commentStr.Contains("10")
Case commentStr.Contains("15")
推荐答案
Select Case True
Case commentStr.Contains("10")
'foo
Case commentStr.Contains("15")
'bar
End Select
请注意,使用此构造,最多将执行 one Case
.
Note that with this construct, a maximum of one Case
will be executed.
(另请注意,您的 C# 朋友不能使用 switch
执行此操作,这需要 case
子句中的常量表达式:))
(Also note that your C# friends can't do this with switch
, which requires constant expressions in the case
clauses :))
这篇关于你能在 Select Case 语句中使用 .Contains(string) 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文