2

As many of you know, c# launched with a new feature "default implementation of interface member".

As per my knowledge this was the major functionality in abstract class. And a user has to choose abstract class if he wants to provide default implementation despite abstract class uses high CPU uses.

As now interface has default implementation, one would like to choose interface in any case.

Apart from constructor[resource initialization] is there any other uses of abstract class? And, is it possible that Microsoft deprecate abstract class?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Sombir Kumar
  • 1,841
  • 1
  • 17
  • 30
  • 2
    abstract classes can still contain *non-overridable* members and fields, neither of which are possible in interfaces. – Damien_The_Unbeliever Feb 07 '19 at 09:06
  • 3
    No, default implementation members are only a tiny bit of an abstract class's functionality. You still can't inherit from multiple abstract classes. They are still classes, with data and implementation, all types of accessibility. – Panagiotis Kanavos Feb 07 '19 at 09:06
  • 1
    Java and PHP also have default implementation members/traits. That doesn't mean they don't have abstract classes. An *InputStream* defines complex functionality and state used by any derived stream class. That can't just go into an interface. You can define some traits like the underlying data type, record length, codepage, encoding, conversions etc as a trait though, that can be used to create different streams from the same base class. – Panagiotis Kanavos Feb 07 '19 at 09:16
  • If you have a default implementation in an abstract class you can always call `base.` from a derived class. Though once you implemented an interface member in a class you can't call its default implementation anymore. – György Kőszeg Feb 07 '19 at 09:27

0 Answers0