I have some code that works like the below. I was wondering if its possible to get a Type object for the generic type passed to the DoSomething function. I realise that T is a type parameter but how would i turn this into a type object. The dosomething function is in a class where I want to know the underlying type used by the list object.
[STAThread]
static void Main(string[] args)
{
List<string> stringList = new List<string>();
DoSomething(stringList);
}
public void DoSomething<T>(List<T> collection)
{
//Type myType = T; ??!!?
//do something here with the list.
}
Many thanks
Will