我想根据属性的名称更改对象中目标属性的值。例子:
// Returns a list of all the properties of an object
PropertyInfo[] properties = GetProperties(myObject);
// Set the values of all properties that contain "Show_" in their name to -1
foreach (PropertyInfo property in properties)
{
if (property.Name.Contains("Show_"))
{
// update myObject's property value to -1
// i.e. something like:
// myObject.(property.Name) = -1;
}
}
我该怎么做呢?
谢谢
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句