Answers for "c# get attribute from property"

C#
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
0

c# get custom attribute from property

PropertyInfo[] propertyInfos = typeof(T).GetProperties(BindingFlags.Public | BindingFlags.Instance);
PropertyInfo p = propertyInfos.Where(x => x.GetCustomAttribute<JsonPropertyAttribute>() != null && x.GetCustomAttribute<JsonPropertyAttribute>().PropertyName == "xx");
Posted by: Guest on December-15-2020

Code answers related to "c# get attribute from property"

C# Answers by Framework

Browse Popular Code Answers by Language