Convert Type object to Type of List<object>

Considering I have the following:

Type objectType = typeof(A);

How can I convert objectType to collectionType? Knowing that collectionType represents the following:

Type collectionType = typeof(IList<A>);

Upvotes: 0

Views: 105

Answers (1)

As @PetSerAl mentioned in the comments, the way to do it is like this:

typeof(IList<>).MakeGenericType(typeof(A))

Upvotes: 4

Related Questions