Im saving an object model out to XML but when i load it back in I get exceptions when trying to use PropertyInfo.SetValue() because the property doesn’t have a setter just a getter.
I want to either not save out the properties that only have getters or figure out on load whether its valid for me to try and set a value or not.
Anybody know how to do this
Cheers
You can use
PropertyInfo.GetSetMethod– this will returnnullif either the property is read-only or the setter is non-public.If you can cope with a non-public setter, you can use: