get property value by property name in C# code example
Example 1: c# get object property value by name
return car.GetType().GetProperty(propertyName).GetValue(car, null);
Example 2: get property value from object c#
Type myType = myObject.GetType();
IList<PropertyInfo> props = new List<PropertyInfo>(myType.GetProperties());
foreach (PropertyInfo prop in props)
{
object propValue = prop.GetValue(myObject, null);
// Do something with propValue
}