获取: 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
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.Collections.Specialized; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Prog
一.定义一个类 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
if (result.success) { var obj = JSON.parse(result.data); var sltObj = document.getElementById("selUser"); //获取select对象 for (var i = 0; i < obj.length; i++) { var optionObj = document.createElement("option"); //创建option对象 optionObj.v
Enum使用 获取枚举属性 注意:扩展方法必须定义为静态类,静态方法中. public enum EnumPatientSource { [Description("住院")] INHOSPITAL = -1, [Description("门诊")] OUTPATIENT = 0, } public static class EnumHelper { public static string ToDescription(this Enum val) { var ty