public class A
        {
            /// <summary>
            /// 字段名称
            /// </summary>
            public string Name
            {
                get;
                set;
            }
        }
 

获取值

      A model= new A(){Name="ABC"};
         string nameOfProperty = "Name";
         var propertyInfo = model.GetType().GetProperty(nameOfProperty);
         var value = propertyInfo.GetValue(model, null).ToString();//值 "ABC"

 

相关文章:

  • 2022-12-23
  • 2021-11-09
  • 2022-12-23
  • 2021-11-01
  • 2021-06-15
  • 2022-12-23
  • 2021-09-06
猜你喜欢
  • 2022-12-23
  • 2021-07-18
  • 2022-12-23
  • 2022-12-23
  • 2021-10-20
  • 2021-11-21
相关资源
相似解决方案