获取: Type type = typeof(ParamServiceType); var values = Enum.GetValues(type); ; i < values.Length; i++) { var v = values.GetValue(i); var member = type.GetMember(v.ToString()); DescriptionAttribute des = (DescriptionAttribute)System.Attribute.GetCusto
/// <summary> /// 获取枚举Description的Name /// </summary> /// <param name="enumName">枚举</param> /// <returns></returns> public static string GetDescription(Enum enumName) { var name = enumName.ToString(); var type
// see at http://swifter.tips/enum-enumerate/ // 貌似有些空格在粘贴的时候没有了... = =! import Foundation enum Suit: String { case Spades = "黑桃" case Hearts = "红桃" case Clubs = "草花" case Diamonds = "方片" }
关键代码: using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Reflection; namespace CSharpUtilHelpV2 { /// <summary> /// 基于.NET 2.0的枚举工具类 /// </summary> public static class EnumToolV2