I would like make an extension method for the generic class A which takes yet another generictype (in this example TC), but i guess that aint possible?
class Program
{
static void Main(string[] args)
{
var a = new A<B, B>();
a.DoIt<B>();
}
}
static class Ext
{
public static A<TA, TB> DoIt<TA, TB, TC>(this A<TA, TB> a)
{
return a;
}
}
class A<TA, TB> { }
class B { }
If you can accept a slight syntax change, then it would be possible.
Change it to:
The trick is that the Do method is an extension method on
A<TA, TB>:The trick is that this signature lets type inferincing pick up TA and TB from
aso that you don’t have to specify them explicitly.The Doer class provides the generic method you need: