Given a basic class definition:
using System.Reflection;
public class Car()
{
public int speed {get;set;}
public void setSpeed()
{
Type type = this.GetType();
PropertyInfo property = type.GetProperty(PropertyName );
property.SetValue(type, Convert.ToInt32(PropertyValue), null);
}
}
This code sample is simplified and not using dynamic type conversion, I just want a working sample to set that property on the instance.
Edit: PropertyName and PropertyValue in above code is also simplified.
Thanks in advance