【发布时间】:2009-03-27 00:17:47
【问题描述】:
假设我有以下声明:
public enum Complexity { Low = 0, Normal = 1, Medium = 2, High = 3 }
public enum Priority { Normal = 1, Medium = 2, High = 3, Urgent = 4 }
我想对其进行编码,以便获得枚举值(不是索引,就像我之前提到的那样):
//should store the value of the Complexity enum member Normal, which is 1
int complexityValueToStore = EnumHelper.GetEnumMemberValue(Complexity.Normal);
//should store the value 4
int priorityValueToStore = EnumHelper.GetEnumMemberValue(Priority.Urgent);
这个可重用的函数应该是什么样子的?
蒂亚! -人
【问题讨论】:
标签: c# function enums generics