Notice the following code. The offending line has been commented out.
interface I<R> { }
class C : I<int> { }
class Program
{
private static void function<T, R>(T t) where T : class, I<R>
{
}
static void Main(string[] args)
{
// function(new C()); // wont compile
function<C, int>(new C());
}
}
I believe type inference should figure out the type because the argument T
provides the first type, while I<R>
provides the second type.
Is there a way to redesign the function so that the callers may not have to specify the types?