什么是带有 case OR-ing 的 VB.NET select case 语句逻辑? [英] What is the VB.NET select case statement logic with case OR-ing?
本文介绍了什么是带有 case OR-ing 的 VB.NET select case 语句逻辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 case 表达式中使用了 Or 语句.
I'm using an Or statement in my case expression.
即使我有一个在这个范围内的值,它也没有找到匹配项.为什么不呢?
Even though I have a value within this range, it didn't find a match. Why not?
示例代码:
Select Case 2
Case 0
' Some logic
Case 1
' Some other logic
Case 2 Or 3
Console.WriteLine("hit")
End Select
根据上述内容,我假设 hit
会被打印出来,但事实并非如此.
With the above I would assume that hit
would be printed, but that's not the case.
推荐答案
使用逗号运算符分隔 case 语句
Use the comma operator to delimit case statements
Select Case 2
Case 0,1,2,3
Console.WriteLine("hit")
End Select
这篇关于什么是带有 case OR-ing 的 VB.NET select case 语句逻辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文