C# programming language is the most popular because every release makes the job easier. From past two decades, it has released seven versions now came up with c# 8.0. Let’s see C# 8.0 features.
New Features In C# 8.0 | C# 8.0 Features
- Default Implementation for Interfaces.
- Light Weight Classes.
- Nullable Types.
Default Implementation for Interfaces in C# 8.0
Default implementation for an interface is an exciting feature in C# 8.0. Until 7.0, we could only see interfaces only with abstract methods but now in .NET framework 8.0 added a default implementation for interface methods.
Using default implementation for interface has made drastic changes in development life cycle.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
// Interfaces in .NET framework 7.0 interface IATM { void Debit(decial amount); void Credit(decial amount); } //Interfaces in .NET framework 8.0 interface IATM { void Debit(decial amount); void Credit(decial amount); // default implementation for interface void Print() { System.console.write("Receipt Printed !!!"); } } |
The default implementation of interfaces will provide a most powerful way to extend the classes that implement interfaces.