public void ClickEdit(TItem clickedItem)
{
Crud = CrudEnum.Update;
foreach (PropertyInfo prop in typeof(TItem).GetProperties())
{
prop.SetValue(EditItem, typeof(TItem).GetProperty(prop.Name).GetValue(clickedItem), null);
}
}
I created the above method to loop through an generic typed instance and use the value of that instance to set values in another instance of the same type.
However, some of the TItem properties are read-only, and then exceptions will be thrown.
What is the proper way to skip properties that are read-only and set only the properties that can be set?
Thanks!
Aucun commentaire:
Enregistrer un commentaire