
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
Abstract Classes in C#
An abstract class in C# includes abstract and non-abstract methods. A class is declared abstract to be an abstract class. You cannot instantiate an abstract class.
Let us see an example, wherein we have an abstract class Vehicle and abstract method display()−
public abstract class Vehicle { public abstract void display(); }
The abstract class has derived classes: Bus, Car, and Motorcycle. The following is an implementation of the Bus derived class −
public class Bus : Vehicle { public override void display() { Console.WriteLine("Bus"); } }
Example
Let us see the complete example of abstract classes in C# −
using System; public abstract class Vehicle { public abstract void display(); } public class Bus : Vehicle { public override void display() { Console.WriteLine("Bus"); } } public class Car : Vehicle { public override void display() { Console.WriteLine("Car"); } } public class Motorcycle : Vehicle { public override void display() { Console.WriteLine("Motorcycle"); } } public class MyClass { public static void Main() { Vehicle v; v = new Bus(); v.display(); v = new Car(); v.display(); v = new Motorcycle(); v.display(); } }
Output
Bus Car Motorcycle
- Related Articles
- What are abstract classes in C#?
- Abstract Classes in Java
- Pure Virtual Functions and Abstract Classes in C++
- Abstract Classes in Dart Programming
- Abstract vs Sealed Classes vs Class Members in C#
- What are abstract classes in Java?
- Abstract Method and Classes in Java
- Abstract Base Classes in Python (abc)
- How to create abstract classes in TypeScript?
- Python Abstract Base Classes for Containers
- Difference between Traits and Abstract Classes in Scala.
- What is the difference between interfaces and abstract classes in Java?
- abstract keyword in C#
- What are abstract properties in C#?
- Nested Classes in C#

Advertisements