Answers for "how to access a property of an object in c# by name"

C#
2

c# get object property value by name

return car.GetType().GetProperty(propertyName).GetValue(car, null);
Posted by: Guest on April-24-2020
0

access object property C#

System.Reflection.PropertyInfo prop = typeof(YourType).GetProperty("PropertyName");

object value = prop.GetValue(yourInstance);
...
prop.SetValue(yourInstance, "value");
Posted by: Guest on May-06-2020

Code answers related to "how to access a property of an object in c# by name"

C# Answers by Framework

Browse Popular Code Answers by Language