枚举整数值

时间:2014-07-25 14:49:19

标签: vb.net

我有一个这样的枚举:

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

当我尝试获取Category999的整数值时,我得到8而不是999.如何获得正确的整数值?

cat = DirectCast(999, Categories)

1 个答案:

答案 0 :(得分:2)

如果你想获得Category999"的"整数值;你这样做:

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