If I have the class name of the user defined object as a string how do I use it in a generic function as Type of the object ?
SomeGenericFunction(objectID);
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.
If you have a string, then the first thing to do is to use
Type.GetType(string), or (preferably)Assembly.GetType(string)to get theTypeinstance. From there, you need to use reflection:where
{target}is the instance for instance methods, andnullfor static methods.For example: