How to get the values of an enum into a SelectList

前端 未结 12 953
醉梦人生
醉梦人生 2020-12-13 11:58

Imagine I have an enumeration such as this (just as an example):

public enum Direction{
    Horizontal = 0,
    Vertical = 1,
    Diagonal = 2
}
12条回答
  •  再見小時候
    2020-12-13 12:46

    To get the value of an enum you need to cast the enum to its underlying type:

    Value = ((int)i).ToString();
    

提交回复
热议问题