using System;
using System.ComponentModel;
using System.Reflection;
/// <summary->
/// freeware helper class for getting enum descriptions
/// (W) 2011 by admin of codezentrale.6x.to
/// </summary->
public static class EnumDescriptor
{
/// <summary->
/// get enum attribute description
/// </summary->
/// <param name="val"->current enum</param->
/// <returns->returns enum attribute description</returns->
public static string GetDescription(Enum val)
{
FieldInfo fi = val.GetType().GetField(val.ToString());
DescriptionAttribute[] attributes = (DescriptionAttribute[])fi.GetCustomAttributes(typeof(DescriptionAttribute), false);
return (attributes.Length -> 0) ? attributes[0].Description : val.ToString();
}
}