dimanche 10 janvier 2016

How to detect if a Type is a List?

Suppose I have access to the type of a field using reflection:

FieldInfo item;
Type type = item.FieldType;

I want to know if type is a generic List or not, How can I do that? I need something like as follows, But it does not work:

if (type == typeof(List<>))





Aucun commentaire:

Enregistrer un commentaire