class Program
    {
        static void Main(String[] args)
        {
            var t = typeof(A);
            var pName = t.GetProperty("Name");
            //4.0或以上版本
            var displayName = pName.GetCustomAttribute<DisplayNameAttribute>();
            Console.WriteLine(displayName.DisplayName);
            Console.ReadKey();
        }
    }


    public class A
    {
        [DisplayName("张三")]
        public String Name { get; set; }
    }

  

相关文章:

  • 2021-12-28
  • 2022-02-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-24
  • 2021-11-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-09-15
  • 2021-09-20
  • 2021-11-18
  • 2021-09-06
相关资源
相似解决方案