We have been using the interfaces for years and know that interfaces are just contracts and the class that inherits them must implement all methods of an interface.
public interface IFeatureOfInterface
{
public void WriteFeature();
}
public class Feature:IFeatureOfInterface
{
public void WriteFeature()
{
Console.WriteLine("Default Interface Methods in C# 8.0");
}
}
Suppose multiple classes are implementing this Interface, and now you want to add some more methods in that interface.
- If we talk about the time before C# 8.0, then you can not do this because it will break all classes implementing that interface, and you must implement that method.
- But with C# 8.0 now, we can add the default implementation of methods, and it will not break all those classes implementing the interface.
public interface IFeatureOfInterface
{
public void WriteFeature();
public void DefaultFeature()
{
Console.WriteLine("Default Feature");
}
}
public class Feature: IFeatureOfInterface
{
public void WriteFeature()
{
Console.WriteLine("Default Interface Methods in C# 8.0");
}
}
So, what are the benefits of using it?
- Without breaking the default implementation, we can add new methods in the interface, but we can do this through an extension method as well ( creating an extension method for your interface).
- The class implementing the interface is not aware of the default implementation of the method.
- Most importantly, default interface methods can avoid the diamond problem

Mau Nguyen VanPosted Jun 12, 2025, 5:05 AM
Take a look at this bug: internal class DefaultInterfaceMemberBug { ??public static void Main() ??{ ????M(new C1()); // Print: 12? ????M(new C2()); // Print: ??, Can you guess? ??} ??static void M(I x) ??{ ????x.M1(); ????x.M2(); ??} } partial interface I { ??public void M1() ??{ ????Console.Write(1); ??} ??public partial void M2(); ??public partial void M2() ??{ ????Console.Write(2); ??} } class C1 : I; class C2 : I { ??public void M1() ??{ ????Console.Write(3); ??} ??public void M2() ??{ ????Console.Write(4); ??} } Now, logically you might expect the output to be: 12?? 34 But that's not what happens. Instead, the output is: 12?? 32 This is not just limited to methods—it can happen with partial properties and partial indexers too. This issue is being tracked here: ?? github.com/dotnet/roslyn/issues/77346 If you’re working with C# interfaces and using newer features like partial or default members, definitely check this out. It’s a subtle bug that could trip you up. . Net team will fix for partial property and partial even, but not for partial method, this fix will make inconsitancy behavior if you want to Design team fix it, please go to github link to comment and vote it up
Anandu G NathPosted Jan 26, 2024, 3:41 AM
Nice Article
Tahir AnsariPosted Dec 10, 2023, 6:30 AM
Nice information! Thank you