Relativity
Relativity

Reputation: 6868

Can we have a generic function with return type same as input parameter type?

Can we have a generic function with return type same as return type of a anonymous function which is a parameter of the first function ?

As shown below ?

  public T Read(List<int> autIds, Func<DataSet, T> executeFn)
    {

    }

I am getting "Cant resolve T" message - Is this something doable?

Upvotes: 2

Views: 197

Answers (1)

MarcinJuraszek
MarcinJuraszek

Reputation: 125650

Yes, but you need to define T:

public T Read<T>(List<int> autIds, Func<DataSet, T> executeFn)

Upvotes: 6

Related Questions