Compare two enum value and return the sequence in CSharp
Description
The following code shows how to compare two enum value and return the sequence.
Example
//from w ww . j av a 2 s . com
using System;
enum Direction { East = 0, West = 2, North = 4, South = 5 };
public class CompareToTest {
public static void Main() {
Direction myVeh = Direction.West;
Direction yourVeh = Direction.East;
Direction otherVeh = Direction.North;
Console.WriteLine( myVeh.CompareTo(yourVeh) > 0 ? "Yes" : "No");
Console.WriteLine( myVeh.CompareTo(otherVeh) > 0 ? "Yes" : "No" );
}
}
The code above generates the following result.