Enum values in a list

前端 未结 5 1055
悲&欢浪女
悲&欢浪女 2021-02-20 11:38

I\'ve a enum class like,

public enum USERTYPE
{
   Permanant=1,
   Temporary=2,
}

in my business object I just declare this enum as

<         


        
5条回答
  •  無奈伤痛
    2021-02-20 12:31

    GetValues returns System.Array, but we know it's really a TEnum[] (that is a one-dimensional array indexed from zero) where TEnum is USERTYPE in your case. Therefore use:

    var allUsertypeValues = (USERTYPE[])Enum.GetValues(typeof(USERTYPE));
    

提交回复
热议问题