Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'  Annotated program -- Keyboard shortcut: 't'    introductory-examples/control-structures/switch-demo.cs - Demonstrations of switch.Lecture 2 - slide 14 : 43
Program 3

/* Right, Wrong */
using System;

class SwitchDemo {
  public static void Main(){
    int j = 1, k = 1;

    /* 
    switch (j) {                                    
      case 0:  Console.WriteLine("j is 0");         
      case 1:  Console.WriteLine("j is 1");
      case 2:  Console.WriteLine("j is 2");
      default: Console.WriteLine("j is not 0, 1 or 2");
    }   
    */

    switch (k) {                                      
      case 0:  Console.WriteLine("m is 0"); break;    
      case 1:  Console.WriteLine("m is 1"); break;
      case 2:  Console.WriteLine("m is 2"); break;
      default: Console.WriteLine("m is not 0, 1 or 2"); break;
    }   

    switch (k) {                                                 
      case 0: case 1:  Console.WriteLine("n is 0 or 1"); break;  
      case 2: case 3:  Console.WriteLine("n is 2 or 3"); break;
      case 4: case 5:  Console.WriteLine("n is 4 or 5"); break;
      default: Console.WriteLine("n is not 1, 2, 3, 4, or 5"); break;
    }   

    string str = "two"; 
    switch (str) {                                          
      case "zero":  Console.WriteLine("str is 0"); break;   
      case "one":  Console.WriteLine("str is 1"); break;    
      case "two":  Console.WriteLine("str is 2"); break;
      default: Console.WriteLine("str is not 0, 1 or 2"); break;
    }   
  }      
}