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

complete-reference-vb_net_12

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)
5 views

complete-reference-vb_net_12

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

To work with the GridVectorsEnum enumeration in our code, reference it with the Imports statement or
directly in the class and declare the type as follows:

Dim Grid As New GridVectorsEnum

Using it in the code couldn't be easier:

If (ObjectPosition >= Grid.MaxRight) Then


'. . . do something
End If

Working with System.Enum

While enumerated types are familiar to many programmers of languages like Delphi and C++, they are much
more useful in the .NET Framework. They are typically processed in the stack area, but can also be boxed
onto the heap as objects.

Every Enum must have an underlying type that represents one of the ordinal built−in types: Byte, Integer,
Long, and Short. If you do not initialize the enumeration constants with values, they default to Integer. The
following example specifies constants of the default Integer type:

Public Enum DaysEnum As Integer


Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Noday
End Enum

When you create and reference enumerated types, they are essentially compiled to constant fields. So the
following Enum called EnumDays,

Public Enum DaysEnum


Sunday = 1
Monday = 2
Tuesday = 3
Wednesday = 4
Thursday = 5
Friday = 6
Saturday = 7
Noday = −1
End Enum

is handled by the compiler as if you had written this:

Class MyDays
Public Const Sunday = 1
Public Const Monday = 2
Public Const Tuesday = 3
Public Const Wednesday = 4
Public Const Thursday = 5
Public Const Friday = 6
Public Const Saturday = 7

250

You might also like