public string this[string propertyName] { get { return _properties[propertyName]; } set { _properties[propertyName] = value; } } code example
Example 1: c# get property using string
public static object GetPropValue(object src, string propName)
{
return src.GetType().GetProperty(propName).GetValue(src, null);
}
Example 2: find class property with string C#
public class MyClass
{
public object this[string property]
{
get
{
return typeof(security).GetProperty(property).GetValue(this, null);
}
set
{
typeof(security).GetProperty(property).SetValue(this, value, null);
}
}
}