您可以使用反射来设置“按名称”属性。
using System.Reflection;...myCustomer.GetType().GetProperty(item.Key).SetValue(myCustomer, item.Value, null);
您还可以使用GetValue读取属性,或使用GetType()。GetProperties()获取所有属性名称的列表,该列表返回PropertyInfo的数组(Name属性包含属性名称)

您可以使用反射来设置“按名称”属性。
using System.Reflection;...myCustomer.GetType().GetProperty(item.Key).SetValue(myCustomer, item.Value, null);
您还可以使用GetValue读取属性,或使用GetType()。GetProperties()获取所有属性名称的列表,该列表返回PropertyInfo的数组(Name属性包含属性名称)