Visual BasicR. NET Unleashed

Team-Fly    

 
Visual Basic .NET Unleashed

By Paul Kimmel

Table of Contents
Chapter 5.  Subroutines, Functions, and Structures

Using Enumerated Types

Types defined using the Enum keyword are implicitly derived from ValueType just as structures are. Enumerated types provide a convenient notation for defining a list of values semantically associated to a named value. As demonstrated earlier, for example, you could use an enumeration EyeColor to constrain valid values for eye colors to realistic colors. In contrast, if you used the Color type, you might end up with indications that someone has mauve or cyan-colored eyes.

Table 5.1 lists the shared members of System.Enum types and provides a brief description for each. You will see these capabilities used where it's appropriate to do so, throughout this book.

Table 5.1. System.Enum Members

Member Description
Format Converts enumerated type to its string representation
GetName Returns the string name of the constant specified
GetNames Returns a string array of all the names in the enumeration
GetUnderlyingType Returns the intrinsic underlying type of the enumeration
GetValues Returns an array of the values of the enumeration
IsDefined Returns a Boolean indicating whether the argument is a member of the enumeration

Table 5.1 introduces the public members of enumerated types, not including the members introduced from the ancestor type Object. The public members defined in every classinherited from the Object classwere shown in Table 2.1 in Chapter 2.


Team-Fly    
Top
 

Категории