Build with an Azure free account. Get USD200 credit for 30 days and 12 months of free services.

Start free today

C# Language Highlights: Default Interface Methods

Play C# Language Highlights: Default Interface Methods

The Discussion

  • User profile image

    Worst C# language feature ever.

  • User profile image

    Most important part of this is missing what about method name clashes.

    interface A(){ M(){ /*a*/ }}
    interface B(){ M(){ /*b*/ }}

    public class C : A, B
    // what default am i calling?
    public void Test(){ M(); }

  • User profile image

    From the design documents I think that default interface methods can only be called when you cast to the interface. They are not directly accessible from an instance of C unless if you override the implementation in C.

    Also it's not explained well why abstract classes are still needed, and the reason is that interfaces still cannot contain state/fields.

  • User profile image
    Hans Wurst

    Throwing a NotImplementedException in a default interface method is probably the worst example you could have picked. Either the new method has a usable default implementation or it should be a breaking change, but deferring the breaking to runtime is just horrible.

  • User profile image
    The color theme is also interesting - what theme is that?
  • User profile image
    Great article
  • User profile image


    You REALLY thought the team didn't think of that??

    If it detects you're using two interfaces with a method with the exact same name for some reason it just gives you this:


Add Your 2 Cents