The code below does not compile:
public static class MyExtensions
{
public static Bar<M> Convert<T,M>(this Foo<T> list)
{
return new Bar<M>();
}
}
public class Program
{
static void Main(string[] args)
{
Foo<int> foo = new Foo<int>();
foo.Convert<double>();
}
}
I have to explicitely specify Foo's generic type:
foo.Convert<int, double>();
Specifying the type during method call would not be necessary, if the extension method had a single generic parameter.
Why? Can I create such an extension method that does not require me to specify Foo's parameter?