One may not always know the Type of an object at compile-time, but may need to create an instance of the Type.
How do you get a new object instance from a Type?
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.
The
Activatorclass within the rootSystemnamespace is pretty powerful.There are a lot of overloads for passing parameters to the constructor and such. Check out the documentation at:
or (new path)
Here are some simple examples: