Enumeration Expressions

The elements of enumeration expressions evaluate the same as their underlying types. In addition to using normal operators, there are additional methods that can be performed with an enum type. An Enum class is used to obtain the majority of functionality shown in this section. Where the Enum class is being used, the capitalized Enum class name prefixes the method call. The examples in this section refer to the following enum:

enum Weekday { Mon = 1, Tue, Wed, Thu, Fri, Sat = 10, Sun };

For C++ Programmers

C# enums have much more functionality than C++ enums.

As a typed value, the enum must be assigned to a variable of its type. For example, the underlying representation of a Weekday enum may default to an integral ...

Get C# Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.