将枚举转化成List<T>的方法如下:
/// <summary> /// 枚举处理工具类 /// </summary> public class EnumHelper { /// <summary> /// 枚举转 List /// </summary> /// <param name="enumType">枚举Type</param> /// <returns>List</returns> public static List<TextValue> ToList(Type enumType, string textFormat = null) { List<TextValue> result = new List<TextValue>(); foreach (var i in Enum.GetValues(enumType)) { var text = Enum.GetName(enumType, i); result.Add(new TextValue() { Text = string.IsNullOrEmpty(textFormat) ? text : string.Format(textFormat, text), Value = i }); } return result; } }