c# 9.0 covariant return types and interfaces

Whilst covariant return types in interfaces are not supported as of C# 9, there is a simple workaround:

    interface A {
        object Method1();
    }

    class B : A {
        public string Method1() => throw new NotImplementedException();
        object A.Method1() => Method1();
    }

Leave a Comment