lundi 8 juin 2020

Reflection: If PropertyInfo implements ICollection [duplicate]

I am using reflection to loop through the properties of an array of objects of type Dynamic.

I am looping through the PropertyInfos, and want to know if the type is implementing an ICollection, but I don't want to define what the collection is, just that it is an ICollection.

What is the syntax to achieve this?

code below:

foreach (PropertyInfo propertyInfo in Item.GetType().GetProperties())
        {
            if (propertyInfo is ICollection<>)
            {

            }
            else
            {

            }
        }




Aucun commentaire:

Enregistrer un commentaire