Does changing the return type of a function for a child type breaks binary compatibility?

后端 未结 2 1346
北荒
北荒 2021-01-20 16:34

Let\'s go straight to it :

Old code :

public interface IFoo {}
public class Foo : IFoo {}
...
public static IFoo Bar() { return new Foo(); }
<         


        
2条回答
  •  孤城傲影
    2021-01-20 16:44

    This breaks binary compatibility, but not (most) compile-time compatibility issues, so it's typically an easy migration.

    Note that it can even be a compile-time break if the client code constructs a delegate from the method.

提交回复
热议问题