获取枚举Description的Name

        /// <summary>
	/// 获取枚举Description的Name
	/// </summary>
	/// <param name="enumName">枚举</param>
	/// <returns></returns>
	public static string GetDescription(Enum enumName)
	{
		var name = enumName.ToString();
		var type = enumName.GetType();
		var fieldInfo = type.GetField(name);
		var arrDesc = (DescriptionAttribute[])fieldInfo.GetCustomAttributes(typeof(DescriptionAttribute), false);
		return arrDesc[0].Description;
	}

  

posted @ 2013-12-27 09:31  等待是一生最初的苍老  阅读(244)  评论(0编辑  收藏  举报