Enumerator Operators

Listing 7.5 showed how to apply the operators assignment (=), equals (==), and increment (++) to enumerators. Numerous other operators can be used with enumerators; they are listed in Table 7.4.

Table 7.4. Operators Applicable to Enumerators
Binary +, -
Unary ++, --, ~
Comparison operators ==, !=, <, >, <=, >=
Logical &, |, ^
Assignment =, +=, -=
Primary sizeof

You have not met all of the symbols displayed in Table 7.4. The operators relevant to enumerators are included here for completeness and overview; they will be discussed in relation to enumerators in due time.

The binary operators + and - cannot be applied to two enumerator types. Instead, they are meant to combine one enumerator operand with one integer value operand, ...

Get C# Primer Plus 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.