VB.Net - 嵌套 Select Case 语句



可以选择语句作为外部选择语句语句序列的一部分。即使内部和外部选择语句的大小写常量包含相同的值,也不会出现冲突。

示例

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
vb.net_decision_making.htm
广告