C# generic list <T> how to get the type of T?

Posted by Daok on Stack Overflow See other posts from Stack Overflow or by Daok
Published on 2009-02-17T15:24:36Z Indexed on 2010/03/30 14:23 UTC
Read the original article Hit count: 447

Filed under:
|
|
|

Hello,

Let say I have a List< T > abc = new List< T >; inside a class public class MyClass<T>//.... Later, when I initialize the class the T because MyTypeObject1. So I have a generic list of List< MyTypeObject1 >.

I would like to know, what type of object the list of my class contain. Example, the list called abc contain what type of object? I cannot do abc[0].GetType(); because the list might contain 0 element. How can I do it?

© Stack Overflow or respective owner

Related posts about c#

Related posts about generics