如何通过一个和类里属性相同的字符串获取具体的值

 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"
萌橙 你瞅啥?
原文地址:https://www.cnblogs.com/daimaxuejia/p/11763847.html