mardi 5 juillet 2016

How to Set Value for Field in winforms c# using Reflection

My Project have this:

private clsDTO_Error DTO_Error; --> Have PropertyName = ID
private clsDTO_Right DTO_Right;
FieldInfo f = this.GetType().GetField(DTO_Error, BindingFlags.NonPublic | BindingFlags.Instance);

This example is working properly

DTO_Right.GetType().GetProperty(PropertyName).SetValue(DTO_Right, "OK", null);

I have a problem in this:

f.FieldType.GetProperty("ID").SetValue(f.FieldType,"ERROR",null);

Any ideas for this?

Thanks!





Aucun commentaire:

Enregistrer un commentaire