I have the following:
interface IGeneric<T> {}
class Test : IGeneric<int> {}
// in an unrelated class
public void foo<T, U>()
where T : IGeneric<U>
{
// do something
}
Now I want to call foo
as follows: foo<Test>()
. But with the code above, it doesn't work, since apparently I need to specify both parameters:
Using the generic method 'MainClass.foo<T,U>()' requires 2 type arguments
Is there any way to make foo<Test>()
work - preferably without having to pass a Test
instance? The compiler should be able to deduce U
(to int
in this case).