How do I create a function which will accept generic object of cla开发者_StackOverflow社区ss as an argument and will also have a generic return type?
If you want the same generic for the input and return types then:
public T DoSomething<T>(T input)
If you want different generics for the input and return types then:
public TReturn DoSomething<TInput, TReturn>(TInput input)
like this:
public T Method<T>(T param)
the method may take as manay generic parameters as are needed to specify the types of the various input and return parameters, so you may also do this:
public T1 Method<T1,T2,T3>(T1 input1, T2 input2, T3 input3);
some information on generic methods on MSDN
精彩评论