1 2 3 4 5 6 7 8 9 10 11 12 | using System; class Foo { delegate void StringAction(string a); void Bar(string a) { } static void Test<T>(Action<T> a) { } void Run() { Test(new StringAction(Bar)); Test(new Action<string>(Bar)); } } |
dXNpbmcgU3lzdGVtOwpjbGFzcyBGb28KewoJZGVsZWdhdGUgdm9pZCBTdHJpbmdBY3Rpb24oc3RyaW5nIGEpOwoJdm9pZCBCYXIoc3RyaW5nIGEpIHsgfQoJc3RhdGljIHZvaWQgVGVzdDxUPihBY3Rpb248VD4gYSkgeyB9Cgl2b2lkIFJ1bigpCgl7CgkJVGVzdChuZXcgU3RyaW5nQWN0aW9uKEJhcikpOwoJCVRlc3QobmV3IEFjdGlvbjxzdHJpbmc+KEJhcikpOwoJfQp9
prog.cs(9,17): error CS0411: The type arguments for method `Foo.Test<T>(System.Action<T>)' cannot be inferred from the usage. Try specifying the type arguments explicitly Compilation failed: 1 error(s), 0 warnings
-
result: Compilation error (maybe you wish to see an example for C#)


