C# Nested-Switch Statement

C# Nested-Switch Statement has a switch statement inside another switch statement. There is a parent switch. The inner switch is present in one of the cases in the parent switch. It is possible to have a switch as part of the statement sequence of an outer switch. Even if the case constants of the inner and outer switch contain common values, no conflicts will arise.


The following example will illustrate C# nested-switch statement.

using System;

namespace DecisionMaking {
   public class Program {
     public  static void Main(string[] args) {
         int x = 23;
         int y = 76;
         switch (x) {
            case 23: 
            Console.WriteLine("Outer switch value ");
            switch (y) {
               case 76:
               Console.WriteLine("Inner switch value ");
         Console.WriteLine("Exact value of X is : {0}", x);
         Console.WriteLine("Exact value of Y is : {0}", y);