Christof Nordiek wrote:
Given the following code
Is there any way to call one of the Bar methods.
using System;
class Program
{
static void Main()
{
Foo<string, stringfoo = new Foo<string,string>();
string s = "";
foo.Bar(s); // Compiler error CS0121
}
}
class Foo<T, S>
{
public void Bar(T a)
{
Console.WriteLine("Bar(T)");
}
public void Bar(S a)
{
Console.WriteLine("Bar(S)");
}
}
Per the spec, it cannot be resolved and should properly fail. See this
example in the spec:
class G2<U,V>
{
void F3(U u, V v); // Valid, but overload resolution
for
void F3(V v, U u); // G2<int,int>.F3 will fail
void F4(U u, I1<Vv); // Valid, but overload resolution for
void F4(I1<Vv, U u); // G2<I1<int>,int>.F4 will fail
void F5(U u1, I1<Vv2); // Valid overload
void F5(V v1, U u2);
void F6(ref U u); // valid overload
void F6(out V v);
}
--
Tom Porterfield