Assume I have a class that is unknown until runtime.
At runtime I get a reference, x, of type Type referencing to Foo.GetType().
Only by using x and List<>, can I create a list of type Foo?
How to do that?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Of course you shouldn’t expect any type safety here as the resulting list is of type
objectat compile time. UsingList<object>would be more practical but still limited type safety because the type ofFoois known only at runtime.