switch statement with Enum and call its ToString function
using System;
enum EmpType : byte {
Manager = 10,
Grunt = 1,
Contractor = 100,
VP = 9
}
class Program {
public static void AskForBonus(EmpType e) {
switch (e) {
case EmpType.Contractor:
Console.WriteLine("1");
break;
case EmpType.Grunt:
Console.WriteLine("2");
break;
case EmpType.Manager:
Console.WriteLine("3");
break;
case EmpType.VP:
Console.WriteLine("4");
break;
default: break;
}
}
static void Main(string[] args) {
EmpType fred;
fred = EmpType.VP;
AskForBonus(fred);
Console.WriteLine(fred.ToString());
}
}
Related examples in the same category