Enum.IsDefined()
using System;
enum EmpType : byte {
Manager = 10,
Grunt = 1,
Contractor = 100,
VP = 9
}
class Program {
static void Main(string[] args) {
EmpType fred;
fred = EmpType.VP;
// Does EmpType have a SaleEmployee value?
if (Enum.IsDefined(typeof(EmpType), "SalesEmployee"))
Console.WriteLine("Yep, we have sales people.");
else
Console.WriteLine("No, we have no profits....");
}
}
Related examples in the same category