Comparing Enumeration Values with CompareTo() : Enums Definition : Data Type C# Examples


C# Examples » Data Type » Enums Definition »

 

Comparing Enumeration Values with CompareTo()









    
using  System;
      
public  class  MainClass
{
        public  enum  Color
        {
                Red  =  0,
                Orange,
                Yellow,
                Green,
                Blue,
                Indigo,
                Violet
        }
      
        static  void  Main()
        {
                Color  MyColor;
      
                MyColor  =  Color.Green;
                Console.WriteLine("{0}",  MyColor.CompareTo(Color.Red));  
                Console.WriteLine("{0}",  MyColor.CompareTo(Color.Green));  
                Console.WriteLine("{0}",  MyColor.CompareTo(Color.Violet));  
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Enums Definition