0% found this document useful (0 votes)
3 views

complete-reference-vb_net_13

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

complete-reference-vb_net_13

Uploaded by

khalid
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Working with System.

Enum
Public Const Noday = −1
End Class

The same goes for the DepreciationPeriodEnum enumeration we used earlier with Accounting structure, as
shown here:

Public Enum DepreciationPeriodEnum


FirstYear = 0
SecondYear = 1
ThirdYear = 2
FourthYear = 3
FifthYear = 4
SixthYear = 5
SeventhYear = 6
EighthYear = 7
NinthYear = 8
TenthYear = 0
End Enum

If you look under the covers of these constant fields, you will not find much. However, with Enum it's
another story. Apart from the inherited members, you also have the marvelous collection of mostly static
utility methods, listed in Table 8−1, at your disposal.

Table 8−1: Member of System.Enum

Enum Members (abridged list) Utility


CompareTo (i) Compares this object to the object passed by value to a single parameter.
The function returns an indication of their relative values.
Format Converts the specified value of an enumerated type to its equivalent String
representation according to the specified format.
GetName Returns the name of the constant passed with the specified enumeration.
GetNames Returns an array of the names in the enumeration passed to the method.
GetTypeCode Returns the TypeCode for the object.
GetUnderlyingType Returns the underlying type for the enumeration.
GetValues Returns an array of the values of the enumeration.
IsDefined Returns a Boolean whether a specified constant exists in the enumeration.
Parse Converts the string representation of the name or value of an enumerated
constant to an equivalent enumerated object.
To return the underlying type of an enumerated type, you can use the GetUnderlyingType method as
follows:

Public Sub EnumUncovered()


Debug.WriteLine(E.GetUnderlyingType(E.Saturday))
End Sub

We can also easily declare the enumerated type in this way:

Dim dayoweek As DayEnum.Saturday


Debug.WriteLine(dayoweek.ToString)

251

You might also like