Pass enum to function : enum switch « Data Type « C# / CSharp Tutorial






using System; 

public enum Week { Monday, Tuesday, Wednesday, Thursday, Friday, Saturaday,Sunday }; 
 
class ConveyorControl { 

 
  public void conveyor(Week com) { 
    switch(com) { 
      case Week.Monday: 
        Console.WriteLine("Starting Monday."); 
        break; 
      case Week.Tuesday: 
        Console.WriteLine("Stopping Tuesday."); 
        break; 
      case Week.Wednesday: 
        Console.WriteLine("Moving Wednesday."); 
        break; 
      case Week.Thursday: 
        Console.WriteLine("Moving Thursday."); 
        break; 
    } 
  } 
} 
 
class MainClass { 
  public static void Main() { 
    ConveyorControl c = new ConveyorControl(); 
 
    c.conveyor(Week.Thursday); 
    c.conveyor(Week.Tuesday); 
    c.conveyor(Week.Wednesday); 
    c.conveyor(Week.Monday); 
     
  } 
}
Moving Thursday.
Stopping Tuesday.
Moving Wednesday.
Starting Monday.








2.39.enum switch
2.39.1.Enums as parameters
2.39.2.Pass enum to function
2.39.3.Switch with enum