I want to have two overloads of a generic method:
public ReturnType<T> DoStuff<T>(T thing) {...}
public ReturnType<T> DoStuff<T>(IEnumerable<T> things) {...}
Trouble is, of course, that an IEnumerable<T>
is itself a type that matches the first signature, so when I try passing a collection to this method, it invokes the first overload.
Obviously I could name the methods differently to remove the ambiguity. But seeing as the methods essentially do the same thing, I'd like to keep them as overloads.
Is there some way of defining T
in the first signature so that it will not accept an IEnumerable
as an argument?