1 using System; 2 3 enum LightColor 4 { 5 Red, 6 Yellow, 7 Green 8 } 9 10 class TrafficLight 11 { 12 public static void WhatInfo(LightColor color) { 13 switch(color) { 14 case LightColor.Red: 15 Console.WriteLine( "Stop!" ); 16 break; 17 case LightColor.Yellow: 18 Console.WriteLine( "Warning!" ); 19 break; 20 case LightColor.Green: 21 Console.WriteLine( "Go!" ); 22 break; 23 default: 24 break; 25 } 26 } 27 } 28 29 class Test 30 { 31 static void Main() 32 { 33 LightColor c = LightColor.Red; 34 Console.WriteLine( c.ToString() ); 35 TrafficLight.WhatInfo( c ); 36 } 37 }