What is the output of the below given code?
public enum WeekDays
public class Demo
public static void Main()
What if you had to compare members within enums? One may want to know if the enum member larger, smaller or equal to another enum member under consideration. To accomplish this we have made use of a method named CompareTo(). This method belongs to the Enum class. An enum is derived from the Enum class. Since Monday is greater than Sunday in our enum WeekDays, the output is 1.
Back To Top