How can I create a function that will have a dynamic return type based on the parameter type?
Like
protected DynamicType Test(DynamicType type) { return ; }
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’d have to use generics for this. For example,
In this example, the ‘
<T>‘ tells the compiler that it represents the name of a type, but you don’t know what that is in the context of creating this function. So you’d end up calling it like…