VB.Net - Nested Select Case嵌套选择案例语句
2018-12-16 13:45 更新
Nested Select Case语句可以将select语句作为外部select语句的语句序列的一部分。 即使内部和外部选择的情况常数包含公共值,也不会出现冲突。
示例:
Module decisions
Sub Main()
'local variable definition
Dim a As Integer = 100
Dim b As Integer = 200
Select a
Case 100
Console.WriteLine("This is part of outer case ")
Select Case b
Case 200
Console.WriteLine("This is part of inner case ")
End Select
End Select
Console.WriteLine("Exact value of a is : {0}", a)
Console.WriteLine("Exact value of b is : {0}", b)
Console.ReadLine()
End Sub
End Module
当上述代码被编译和执行时,它产生以下结果:
This is part of outer case
This is part of inner case
Exact value of a is : 100
Exact value of b is : 200
以上内容是否对您有帮助:
更多建议: