zoukankan      html  css  js  c++  java
  • .net 读取实体属性和描述注释

    .net 读取实体属性和描述注释

    class
    Program { static void Main(string[] args) { TEST test = new TEST(); test.MyName = "zhangkeyi"; //PropertyInfo[] peroperties = typeof(TEST).GetProperties(BindingFlags.Public | BindingFlags.Instance); PropertyInfo[] peroperties = (((object)test).GetType()).GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (PropertyInfo property in peroperties) { object[] objs = property.GetCustomAttributes(typeof(DescriptionAttribute), true); if (objs.Length > 0) { Console.WriteLine("{0}: {1}", property.Name, ((DescriptionAttribute)objs[0]).Description); } } Console.ReadKey(); } } class TEST { [Description("名称")] public string MyName { get; set; } }
  • 相关阅读:
    ajax01
    django04
    数据库
    WeakHashMap类
    IdentityHashMap
    Hashtable类
    LinkedHashMap类
    HashMap和TreeMap类
    PriorityQueue
    Synchronized
  • 原文地址:https://www.cnblogs.com/liyanbofly/p/4397793.html
Copyright © 2011-2022 走看看