Click here to Skip to main content
15,666,726 members
Articles / Containers

Stats

24.9K views
135 downloads
8 bookmarked

How to Get a Collection Element Type Using Reflection in C#

Rate me:
Please Sign up or sign in to vote.
4.36/5 (12 votes)
5 May 2020MIT3 min read
This tip shows you a robust way to get the type of items a collection can hold. It works with non-generic collections too.
This tip provides a way to query a collection type to determine the types of items it can hold. It support both generic collections and non-generic collections, using a variety of queries to ensure it's relatively robust.

Views

Daily Counts

Downloads

Weekly Counts

License

This article, along with any associated source code and files, is licensed under The MIT License


Written By
United States United States
Just a shiny lil monster. Casts spells in C++. Mostly harmless.

Comments and Discussions