Advertisement

Default Interface Methods in C# 8 - A deep dive

Default Interface Methods in C# 8 - A deep dive In this video, I am going to deep dive into Default Interface Methods in C# 8. This was released along with .Net Core 3.0 in September 2019. I have covered this topic briefly previously in my video. But at that time I was not sure of the potential of this feature. Now, after going through the details of the feature, I am ready to take a deep dive into it.

The main highlights I am going to cover in this video are:
1. What is Default Interface Methods
2. An example of Default Interface Methods
3. Solution provided for multiple inheritance problem
4. Why I think we don't need default interface methods

By definition, the default interface method is a method you can define (not just declare, but provide implementation as well) inside of an interface, without breaking the classes which implement the interface. To elaborate, now we can have a method with complete implementation inside of an interface. Which was not possible pre-C# 8.

Let's talk about what are the advantages of doing that. Well, if you want to extend an interface after it's been released in production without breaking all the clients that implemented this interface, then the default interface method is your answer. By the way, I am going to contradict this statement later in this blog, but lets first continue with the details.

Another important thing to note, though the feature is called default interface methods. In reality, it can be any member, including method, indexer, property or event.

This feature is equivalent to Trait in other Object-Oriented Programming Languages like PHP or Functional Programming Language like Scala. Trait is an Object-Oriented Programming concept.

The detail information about default interface methods is available in my blog post:

default interface methods,c# 8,c#,.net core,.net core 3.0,.net core 3,default interface methods in c# 8,default interface methods c# 8,default interface methods c#,

Post a Comment

0 Comments