13.07.2015 Views

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

C# Language Specification - Willy .Net

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>C#</strong> LANGUAGE SPECIFICATIONEnum members are named and scoped in a manner exactly analogous to fields within classes. The scope ofan enum member is the body of its containing enum type. Within that scope, enum members can be referredto by their simple name. From all other code, the name of an enum member must be qualified with the nameof its enum type. Enum members do not have any declared accessibility—an enum member is accessible ifits containing enum type is accessible.21.4 Enum values and operationsEach enum type defines a distinct type; an explicit enumeration conversion (§13.2.2) is required to convertbetween an enum type and an integral type, or between two enum types. The set of values that an enum typecan take on is not limited by its enum members. In particular, any value of the underlying type of an enumcan be cast to the enum type, and is a distinct valid value of that enum type.Enum members have the type of their containing enum type (except within other enum member initializers:see §21.3). The value of an enum member declared in enum type E with associated value v is (E)v.The following operators can be used on values of enum types: ==, !=, , = (§14.9.5), + (§14.7.4),- (§14.7.5), ^, &, | (§14.10.2), ~ (§14.6.4), ++, -- (§14.5.9 and §14.6.5), and sizeof (§25.5.4).Every enum type automatically derives from the class System.Enum (which, in turn, derives fromSystem.ValueType and object). Thus, inherited methods and properties of this class can be used onvalues of an enum type.296

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

Saved successfully!

Ooh no, something went wrong!