What is wrong with this, and should I be doing to pass a type to a generic?
Type t = typeof(string);
var someThing = new SomeThing<t>(100);
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.
You have to use reflection to do this:
This won’t be that useful though since you will not be able to use the type in a generic way but this approach can be helpful if you need to dynamically construct a generic type for an API call.