You could use the Type.GetGenericArguments
method for this purpose.
List<Foo> myList = ...
Type myListElementType = myList.GetType().GetGenericArguments().Single();
More Related Contents:
- iterating through item of array of generic collections
- How to create List of open generic type of class?
- What is the best way to clone/deep copy a .NET generic Dictionary?
- How do I override List’s Add method in C#?
- .NET – Convert Generic Collection to DataTable
- Accessing a property of derived class from the base class in C#
- What is ‘1 in Collection type Name
- Returning ‘IList’ vs ‘ICollection’ vs ‘Collection’
- What’s Wrong with an ArrayList?
- Convert List to List
- What exactly is an “open generic type” in .NET? [duplicate]
- Select N random elements from a List in C#
- A generic list of anonymous class
- What .NET collection provides the fastest search
- Why isn’t ArrayList marked [Obsolete]?
- Collection of generic types
- Does .NET have a built-in EventArgs?
- Does the Enumerator of a Dictionary return key value pairs in the order they were added?
- C# LINQ to SQL: Refactoring this Generic GetByID method
- The type must be a reference type in order to use it as parameter ‘T’ in the generic type or method
- Why does C# (4.0) not allow co- and contravariance in generic class types?
- Is this a covariance bug in C# 4?
- Case-INsensitive Dictionary with string key-type in C#
- Cast Int to Generic Enum in C#
- find common items across multiple lists in C#
- What is the equivalent of Java wildcards in C# generics
- Overload resolution issue for generic method with constraints
- The given key was not present in the dictionary. Which key?
- Can you use “where” to require an attribute in c#?
- C# List: why you cannot do `List foo = new List();`