<?xml version="1.0"?>
<clause number="21.1" title="Enum declarations">
  <paragraph>An enum declaration declares a new enum type. An enum declaration begins with the keyword enum, and defines the name, accessibility, underlying type, and members of the enum. <grammar_production><name><non_terminal where="21.1">enum-declaration</non_terminal></name> : <rhs><non_terminal where="24.2">attributes</non_terminal><opt/><non_terminal where="21.2">enum-modifiers</non_terminal><opt/><keyword>enum</keyword><non_terminal where="9.4.2">identifier</non_terminal><non_terminal where="21.1">enum-base</non_terminal><opt/><non_terminal where="21.1">enum-body</non_terminal><terminal>;</terminal><opt/></rhs></grammar_production><grammar_production><name><non_terminal where="21.1">enum-base</non_terminal></name> : <rhs><terminal>:</terminal><non_terminal where="11.1">integral-type</non_terminal></rhs></grammar_production><grammar_production><name><non_terminal where="21.1">enum-body</non_terminal></name> : <rhs><terminal>{</terminal><non_terminal where="21.3">enum-member-declarations</non_terminal><opt/><terminal>}</terminal></rhs><rhs><terminal>{</terminal><non_terminal where="21.3">enum-member-declarations</non_terminal><terminal>,</terminal><terminal>}</terminal></rhs></grammar_production></paragraph>
  <paragraph>Each enum type has a corresponding integral type called the underlying type of the enum type. This underlying type must be able to represent all the enumerator values defined in the enumeration. An enum declaration may explicitly declare an underlying type of <keyword>byte</keyword>, <keyword>sbyte</keyword>, <keyword>short</keyword>, <keyword>ushort</keyword>, <keyword>int</keyword>, <keyword>uint</keyword>, <keyword>long</keyword> or <keyword>ulong</keyword>. <note>[Note: <keyword>char</keyword> cannot be used as an underlying type. end note]</note> An enum declaration that does not explicitly declare an underlying type has an underlying type of <keyword>int</keyword>. </paragraph>
  <paragraph>
    <example>[Example: The example <code_example><![CDATA[
enum Color: long  
{  
   Red,  
   Green,  
   Blue  
}  
]]></code_example>declares an enum with an underlying type of <keyword>long</keyword>. end example]</example>
    <note>[Note: A developer might choose to use an underlying type of <keyword>long</keyword>, as in the example, to enable the use of values that are in the range of <keyword>long</keyword> but not in the range of <keyword>int</keyword>, or to preserve this option for the future. end note]</note>
  </paragraph>
</clause>
