LB Elbino

LB Elbino

  • NA
  • 4
  • 0

Create a generic list List where T is only known at runtime

Nov 9 2007 10:00 AM
Please help,
I have a method that returns an Object.  This returned object could be a generic list of 4 or more classes in my code.
i.e the object could be List<class1>, List<class2>, List<class3> etc.
At runtime when I recieve this object, I want to be able to cast it to a list of the appropriate type. 
PS.  The methods return value is object.  The writers of this class that I'm calling basically create a generic list and fill it up, then for reason i cant explain, they cast the list to an object and return is. 
The return line is exactly ==> return (object)thegeneicList
How do I go about creating a generic list List<T> where T is only known at runtime
 

Answers (2)