vendredi 16 avril 2021

C# - How to set a value of a child of a field acquired by Refelctions

So, I have some objects (various types), that have another objects as fields (also various types). And that objects have let's say a float field. How can I set the last one, since I don't have that 'middle' object which reflection requires?

I'm getting it in that way:

FieldInfo field = foo.GetType().GetField(name1).FieldType.GetField(name2);

And here comes my problem:

field.SetValue(object_that_i_dont_have, float_value);





Aucun commentaire:

Enregistrer un commentaire