I would like to change the value of targeted properties within my object depending on the property's name. Example:
// 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;
}
}
How would I go about doing this?
Thanks
Aucun commentaire:
Enregistrer un commentaire