Create empty cases which can fall through in CSharp

Description

The following code shows how to create empty cases which can fall through.

Example


//  w  ww.ja  v a2s.  c o  m
using System; 
 
public class MainClass {     
  public static void Main() { 
    int i; 
 
    for(i=1; i < 5; i++)  
      switch(i) { 
        case 1: 
        case 2: 
        case 3: Console.WriteLine("i is 1, 2 or 3"); 
          break; 
        case 4: Console.WriteLine("i is 4"); 
          break; 
      } 
 
  } 
}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception