C# Language Enum Default value for enum == ZERO

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


The default value for an enum is zero. If an enum does not define an item with a value of zero, its default value will be zero.

public class Program
    enum EnumExample
        one = 1,
        two = 2
    public void Main()
        var e = default(EnumExample);
        if (e == EnumExample.one)
            Console.WriteLine("defaults to one");

Example: https://dotnetfiddle.net/l5Rwie

Got any C# Language Question?