1.定义枚举类型 public enum Test { 男 = , 女 = } 2.获取枚举值 public void EnumsAction() { var s = Test.男;//男 var a = Test.男.ToString();//"男" ;//女 var x = (Test)Enum.Parse(typeof(Test), "男");//男 var x2 = Enum.Parse(typeof(Test), "男");//男 );…
一.定义一个类 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Reflection; namespace XXX.XXX.Utils { /// <summary> /// 备注特性 /// </summary> public class DescAttribute : A…
using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace candel { class Program { static void Main(string[] args) { int x = (in…
var ent = new Ent(); foreach (var item in ent.GetType().GetProperties()) { var v = (DescriptionAttribute[])item.GetCustomAttributes(typeof(DescriptionAttribute), false); ].Description; item.SetValue(ent,descriptionName+":1"); } private class Enu…