Essential C# Enum  Suggest an edit

Default value for enum ZERO

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");
        else
            Console.WriteLine("Unknown");    
    }    
}

Example: https://dotnetfiddle.net/l5Rwie


Table Of Contents
22 Enum
25 GUID
107 Stream
108 Timers
  ↑ ↓ to navigate     ↵ to select     Esc to close