Enum.IsDefined()

image_pdfimage_print
   
   
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....");
    }
}

   
    
     


This entry was posted in Data Types. Bookmark the permalink.