Back to course

Abstract Classes and Methods

.NET Zero to Hero: Master C# and Modern App Development

Abstraction

An abstract class is a restricted class that cannot be used to create objects. To access it, it must be inherited from another class.

Abstract Method:

Can only be used in an abstract class, and it does not have a body. The body is provided by the derived class.

csharp abstract class Animal { public abstract void MakeSound(); // No body }

class Cat : Animal { public override void MakeSound() => Console.WriteLine("Meow"); }