June 2008
Intermediate to advanced
784 pages
20h 36m
English
An enumeration is a set of discrete and related values. You would use an enumeration if you wanted to create a variable that is limited to a set of values, such as one that represents months or one that includes a list of flags. Enumerations expand into a type where the members of the enumeration are defined as constants. The default underlying type of an enumeration is integer. An enumeration is never required; an integer variable can be used directly instead. However, enumerations are safer and more extensible than integer variables, and they enhance readability. In the following sample code, the Months.GetMonth method outputs the name of a month. The method relies on integer values:
public class Months { static public void GetMonth(int ...Read now
Unlock full access