关键代码: 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…
在C#中,枚举用来定状态值很方便,例如我定义一个叫做Season的枚举 public enum Season { Spring = 1, Summer = 2, Autumn = 3, Winter = 4 } 枚举名是不能出现空格,()-/等字符 我们想把Spring显示为春天,我们要自己定义说明信息,我们可以使用DescriptionAttribute,如下 public enum Season { [Description("春 天")] Spring = 1, [Descrip…
将某个值转换为String类型 1. value.toString() toString()方法返回一个表示该对象的字符串 var a = 123 a.toString() // '123' 2. "" + value 一元加法运算符的作用是数值求和,或者字符串拼接.有字符串,则是字符串拼接.其他是数字相加求和. var a = 123 '' + a // '123' 3. String(value) String函数将其他值转换为字符串 var a = 123 String(a) /…