C#, Dynamically accessing properties with a String

Hi there, to make it short, I need to set and get the value of a property of a component using a string. I found this code which is, I believe, supposed to work:

component.GetType().GetProperty("property").GetValue(component, null); component.GetType().GetProperty("property").SetValue(component, "value", null);

But it does not work, it returns absolutely nothing, when I try


I did not include “GetValue”, because GetProperty returns nothing, an empty line, not even a “null”

I’m one week old in C# so my knowledge is rather limited, Is there something special to do in order for it to work, or any workaround for this?


I had similar problems when using reflection, I found that looking for fields instead of properties worked. have you tried that?

(reposting comment as answer)