using System.Reflection
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(EnumMethod.StringValue(CampaignModeEnum.Outbound_Predictive));
Console.ReadLine();
}
}
/// <summary>
/// Campaign Mode
/// </summary>
public enum CampaignModeEnum
{
/// <summary>
/// Inbound
/// </summary>
[DescriptionAttribute("入站")]
Inbound,
/// <summary>
/// Outbound Preview
/// </summary>
[DescriptionAttribute("出站预览")]
Outbound_Preview,
/// <summary>
/// Outbound Predictive
/// </summary>
[DescriptionAttribute("出站预测")]
Outbound_Predictive
}
public static class EnumMethod
{
public static string StringValue(Enum value)
{
FieldInfo fi = value.GetType().GetField(value.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
if (attributes.Length > 0)
{
return attributes[0].Description;
}
else
{
return value.ToString();
}
}
}
}