Yes, this is an amazing change. Every time you make an invalid conversion legal, it is a violation.
Unfortunately, it is very difficult to add functions to the language without any changes. There are several more events in C # 4 if you really want to find them. This is unlikely to affect most developers, of course.
Similar violations were changed between C # 1 and C # 2, where the implementation used would change between different versions for this code:
using System; public delegate void StringAction(string x); public class Base { public void Foo(string x) { Console.WriteLine("Base"); } } public class Child : Base { public void Foo(object x) { Console.WriteLine("Child"); } } public class Test { static void Main() { Child c = new Child(); StringAction action = new StringAction(c.Foo); action("x"); } }
In this case, the compiler does issue a warning:
Test.cs(26,31): warning CS1707: Delegate 'StringAction' bound to 'Child.Foo(object)' instead of 'Base.Foo(string)' because of new language rules
source share