The first reason that comes to mind is the following.
class Example : Y<int,int> { ... }
In this case, type Y implements the same interface twice, but may have different implementations of the same method. This creates an unsolvable ambiguity in the compiler for the Tx method, both for implementation and for invocation.
For example, complete the following task.
class OtherExample<A,B> : Y<A,B> { B Tx(A x) { Console.WriteLine("Top method in the file"); return default(B); } A Tx(B x) { Console.WriteLine("Bottom method in the file"); return default(A); } }
If you ignore the merge error, this is the legal implementation of Y<A,B> . Now imagine that the user has completed the following
var v1 = new OtherExample<int,int>(); v1.Tx(42);
What exactly will happen in this scenario? How could the compiler or CLR solve this ambiguity? You would have identically named methods with identical signatures.
source share