PitAttack76
PitAttack76

Reputation: 2220

Enum integer value

I have an Enum like this:

    Public Enum Categories
    Category1 = 1
    Category2 = 2
    Category3 = 3
    Category4 = 4
    Category5 = 5
    Category6 = 6
    Category7 = 7
    Category999 = 999
End Enum

When I try to get the integer value of Category999 I get 8, and not 999. How can I get the correct integer value?

cat = DirectCast(999, Categories)

Upvotes: 0

Views: 3817

Answers (1)

Magnus
Magnus

Reputation: 46909

If you want to get the "integer value of Category999" you do:

Dim intValue As integer = DirectCast(Categories.Category999, integer)

Upvotes: 2

Related Questions