---
title: "What is the difference between Interface and Abstract Class in C#?"  
description: "What is the difference between Interface and Abstract Class in C#?"  
author: "Ravi Vishwakarma"  
published: 2021-11-29  
updated: 2023-06-06  
canonical: https://www.mindstick.com/interview/33851/what-is-the-difference-between-interface-and-abstract-class-in-c-sharp  
category: "c#"  
tags: ["c#", ".net"]  
reading_time: 4 minutes  

---

# What is the difference between Interface and Abstract Class in C#?

Here are some of the common differences between an interface and an abstract class in C#.

1. An abstract class can have non-abstract methods (concrete methods) while in case of interface, all the methods have to be abstract.\
2. An abstract class can declare or use any variables while an interface is not allowed to do so.
3. In an abstract class, all data members or functions are private by default while in an interface all are public, we can’t change them manually.
4. In an abstract class, we need to use abstract keywords to declare abstract methods, while in an interface we don’t need to use that.
5. An abstract class can’t be used for multiple inheritance while the interface can be used as multiple inheritance.
6. An abstract class use constructor while in an interface we don’t have any type of constructor.

## Answers

### Answer by Aryan Kumar

An interface and an abstract class are both types that cannot be instantiated directly. However, there are some key differences between the two.

- **Abstract classes can contain implemented methods, while interfaces only contain method signatures.** This means that a class that inherits from an abstract class can call the implemented methods directly, while a class that implements an interface must provide its own implementation of the methods in the interface.
- **Classes can implement multiple interfaces, but they can inherit from only one abstract class.** This gives classes more flexibility in terms of the functionality they can provide. For example, a class could implement the ISerializable interface to allow it to be serialized to a stream, and the IComparable interface to allow it to be compared to other objects.
- **Abstract classes can have constructors, while interfaces cannot.** This means that an abstract class can be used to initialize the state of its subclasses, while an interface cannot.
- **Abstract classes can have fields and properties, while interfaces can only have properties.** This is because fields and properties are data members, while interfaces are only concerned with the behavior of a class.

In general, abstract classes are used when there is a common set of functionality that a group of classes should share. Interfaces are used when there is a set of requirements that a class must meet, but the implementation of those requirements is not important.

Here is a table that summarizes the key differences between abstract classes and interfaces:

| Feature | Abstract Class | Interface |
| --- | --- | --- |
| Can be instantiated | No | No |
| Can contain implemented methods | Yes | No |
| Can inherit from multiple classes | No | Yes |
| Can have constructors | Yes | No |
| Can have fields and properties | Yes | No |
| Used for | Sharing common functionality | Enforcing requirements |

Here are some examples of how abstract classes and interfaces can be used in C#:

- An abstract class could be used to represent a shape. The abstract class could define methods for getting and setting the shape's dimensions, as well as a method for drawing the shape. The abstract class could also have a constructor that initializes the shape's dimensions.
- An interface could be used to represent a sortable object. The interface could define a method for comparing two objects. This interface could be implemented by any class that needs to be able to be sorted.

### Answer by Ravi Vishwakarma

Here are some of the common differences between an interface and an abstract class in C#.

1. An abstract class can have non-abstract methods (concrete methods) while in case of interface, all the methods have to be abstract.\
2. An abstract class can declare or use any variables while an interface is not allowed to do so.
3. In an abstract class, all data members or functions are private by default while in an interface all are public, we can’t change them manually.
4. In an abstract class, we need to use abstract keywords to declare abstract methods, while in an interface we don’t need to use that.
5. An abstract class can’t be used for multiple inheritance while the interface can be used as multiple inheritance.
6. An abstract class use constructor while in an interface we don’t have any type of constructor.


---

Original Source: https://www.mindstick.com/interview/33851/what-is-the-difference-between-interface-and-abstract-class-in-c-sharp

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
