How to list Enum's members

后端 未结 4 1850
不思量自难忘°
不思量自难忘° 2021-02-04 02:36

How to list Enum\'s members in code? I have the following Enum:

Public Enum TestEnum As int32
    First = 0
    Second = 2
    Third = 4
    Fourth = 6
End Enum
         


        
4条回答
  •  既然无缘
    2021-02-04 02:44

    Have you looked at Enum.GetValues ?

    Edit: To clarify, yes you need to pass a Type not an instance of the enum to either method.

    Enum.GetNames(GetType(TestEnum))
    

提交回复
热议问题