...

/

Inheriting from Abstract Class

Inheriting from Abstract Class

Learn about inheriting from abstract classes in C# and understand the concepts of polymorphism, method hiding, and overriding for altering method behavior in derived classes.

We learned about interfaces that can define a set of members that a type must have to meet a basic level of functionality. These are very useful, but their main limitation is that until C# 8, they could not provide any implementation of their own. This is a particular problem if we still need to create class libraries that will work with the .NET Framework and other platforms that do not support .NET Standard 2.1.

Abstract classes

In those earlier platforms, we could use abstract classes as a sort of halfway house between a pure interface and a fully implemented class. When a class is marked as abstract, this means that it cannot be instantiated because we are indicating that the class is not complete. It needs more implementation before it can be instantiated. For example, the System.IO.Stream class is abstract because it implements common functionality that all streams would need, but is not complete, so ...