Possible Duplicate:
General Methods and Method Overloading
Say I have a class like
class SortedList<K>
{
public string this[int i] { get { return "a"; } }
public string this[K key] { get { return "b"; } }
}
Now let's say that some dude decided to use it:
static string Test1<K>(K key) { return new SortedList<K>()[key]; }
The compiler resolves this call to overload K key.
Now compare this to the words
static string Test2(int key) { return new SortedList<int>()[key]; }
where the compiler resolves this with overload int i.
Now, if some poor soul speaks Test1(0), he will get a different result if he says Test2(0), although the bodies look almost the same at first glance.
, .
, , .
?
, , ( ) - ?