I have a List<T>
of element and a PropertyInfo
with a list of the property of T
.
How can I identify a single property of an element in a loop ?
Ideally :
List<T>[i].PropertyInfo[y].Name
I have a List<T>
of element and a PropertyInfo
with a list of the property of T
.
How can I identify a single property of an element in a loop ?
Ideally :
List<T>[i].PropertyInfo[y].Name
If you are looking for the type of the properties, you must use the property:
PropertyInfo.PropertyType
If i understood the question currently and you're looking to match the two collections, then you could use the type of the property info(Has a property type Property) and the typeof(T). For efficiency i would recommend creating a dynamic method that would be cached for future usage.
I solved the problem using a solution like the one in the post "Get property value from string using reflection in C#".