Answers for "c# get value of property on object"

C#
1

how to get value from object in c#

var nameOfProperty = "property1";
var propertyInfo = myObject.GetType().GetProperty(nameOfProperty);
var value = propertyInfo.GetValue(myObject, null);
Posted by: Guest on November-21-2019
1

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
}
Posted by: Guest on January-06-2021

Code answers related to "c# get value of property on object"

C# Answers by Framework

Browse Popular Code Answers by Language