I have a simple class with 2 properties:
class Circle {
protected int x = 0 {get; set;}
protected int y = 0 {get; set;}
}
I have another class where the user can write which property he wants to change.
string selectProperty = Input.ReadString("Write which property to you want to change");
In the same class I have a circle object, and I just want to change the value of a property according to his selection, to 5.
circle.selectProperty = 5;
This is just small example, I want to know the main idea, so 2 small "if"s won't help...
Thank you!
circle.GetType().GetProperty(selectProperty).SetValue(circle, 5)protected, you can change it topublicor use Bindingflags overload inGetPropertymethod.