An abstract class is a way to achieve the abstraction in C#. An Abstract class is never intended to be instantiated directly. This class must contain at least one abstract method, which is marked by the keyword or modifier abstract in the class definition. The Abstract classes are typically used to define a base class in the class hierarchy.
Class name is G1 Class name is G2
Like a class, Interface can have methods, properties, events, and indexers as its members. But interfaces will contain only the declaration of the members. The implementation of interface’s members will be given by the class who implements the interface implicitly or explicitly.
Welcome to GeeksforGeeks!!!
Difference between Abstract Class and Interface
|It contains both declaration and definition part.||It contains only a declaration part.|
|Multiple inheritance is not achieved by abstract class.||Multiple inheritance is achieved by interface.|
|It contain constructor.||It does not contain constructor.|
|It can contain static members.||It does not contain static members.|
|It can contain different types of access modifiers like public, private, protected etc.||It only contains public access modifier because everything in the interface is public.|
|The performance of an abstract class is fast.||The performance of interface is slow because it requires time to search actual method in the corresponding class.|
|It is used to implement the core identity of class.||It is used to implement peripheral abilities of class.|
|A class can only use one abstract class.||A class can use multiple interface.|
|If many implementations are of the same kind and use common behavior, then it is superior to use abstract class.||If many implementations only share methods, then it is superior to use Interface.|
|Abstract class can contain methods, fields, constants, etc.||Interface can only contain methods .|
|It can be fully, partially or not implemented.||It should be fully implemented.|
- C# | Abstract Classes
- Difference between Class and Structure in C#
- C# | Interface
- C# | How to use Interface References
- C# | Explicit Interface Implementation
- Default Interface Methods in C# 8.0
- C# | Class and Object
- Difference between SortedList and SortedDictionary in C#
- Difference between Managed and Unmanaged code in .NET
- C# | Difference between Static Constructors and Non-Static Constructors
- Difference between Ref and Out keywords in C#
- Difference between Python and C#
- Difference between System Level Exception and Application Level Exception in C#
- Difference between readonly and const keyword in C#
- Difference between Hashtable and Dictionary in C#
- Difference between Method Overriding and Method Hiding in C#
- Difference between var and dynamic in C#
- Difference between Boxing and Unboxing in C#
- Difference between C and C#
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.