






















public static string GetStringValue(this Enum value)
{
Type type = value.GetType();
FieldInfo fieldInfo = type.GetField(value.ToString());
StringValueAttribute[] attribs = fieldInfo.GetCustomAttributes(typeof(StringValueAttribute), false) as StringValueAttribute[];
return attribs.Length > 0 ? attribs[0].StringValue : null;
}
class StringValueAttribute : Attribute
{
private string stringvalue = string.Empty;
public string StringValue
{
get { return stringvalue; }
set { stringvalue = value; }
}
public StringValueAttribute(string value)
{
stringvalue = value;
}
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。