Useful Methods from
As mentioned at the beginning of this section, all enumerations derive from the
System.Enum class. Such a type exposes some shared methods that enable performing operations on enumerations. This subsection explains how you can take advantage of methods for working on enumerations.
The first two methods described are
GetNames. Both enable retrieving an array of items stored within an enumeration, but
GetValues gets an array of integers corresponding to the numeric values of enumerations’ items whereas
GetNames retrieves an array of strings storing the names of enumerations’ items. Continuing the example of the
Sports enumeration, consider the following code:
This code’s output ...