13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>C#</strong> LANGUAGE SPECIFICATIONenum-modifier:newpublicprotectedinternalprivateIt is a compile-time error for the same modifier to appear multiple times in an enum declaration.The modifiers of an enum declaration have the same meaning as those of a class declaration (§17.1.1).However, the abstract and sealed modifiers are not permitted in an enum declaration. Enums cannot beabstract and do not permit derivation.21.3 Enum membersThe body of an enum type declaration defines zero or more enum members, which are the named constantsof the enum type. No two enum members can have the same name.enum-member-declarations:enum-member-declarationenum-member-declarations , enum-member-declarationenum-member-declaration:attributes opt identifierattributes opt identifier = constant-expressionEach enum member has an associated constant value. The type of this value is the underlying type for thecontaining enum. The constant value for each enum member must be in the range of the underlying type forthe enum. [Example: The exampleenum Color: uint{Red = -1,Green = -2,Blue = -3}results in a compile-time error because the constant values -1, -2, and –3 are not in the range of theunderlying integral type uint. end example]Multiple enum members may share the same associated value. [Example: The exampleenum Color{Red,Green,Blue,}Max = Blueshows an enum that has two enum members—Blue and Max—that have the same associated value. endexample]The associated value of an enum member is assigned either implicitly or explicitly. If the declaration of theenum member has a constant-expression initializer, the value of that constant expression, implicitlyconverted to the underlying type of the enum, is the associated value of the enum member. If the declarationof the enum member has no initializer, its associated value is set implicitly, as follows:• If the enum member is the first enum member declared in the enum type, its associated value is zero.• Otherwise, the associated value of the enum member is obtained by increasing the associated value ofthe textually preceding enum member by one. This increased value must be within the range of valuesthat can be represented by the underlying type.294

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!