C# Abstract Class vs Interface: Choosing the Right Abstraction
Compare C# abstract classes and interfaces: syntax, capabilities, use cases, and tradeoffs to choose the right abstraction for your type design.

Choosing between an abstract class and an interface is one of the most common design decisions in C#. Both define contracts for derived types, but they differ in how they handle implementation, inheritance, and evolution. Understanding these differences helps you avoid rigid designs that become hard to change later.
The Core Difference: Contract vs. Shared Implementation
An interface defines a contract that implementing types must fulfill. It declares members—methods, properties, events, and indexers—and, in classic C#, provides no implementation. An abstract class can provide both abstract members (with no body) and concrete members with full implementations. This distinction drives most of the practical differences.
public interface ILogger
{
void Log(string message);
}
public abstract class BaseLogger
{
public abstract void Log(string message);
public void LogWithTimestamp(string message)
{
Log($"{DateTime.UtcNow}: {message}");
}
}In this example, ILogger forces any implementing class to provide Log. BaseLogger also forces that, but additionally provides a reusable LogWithTimestamp method that calls the abstract Log. The abstract class can share behavior with derived classes; a classic interface cannot, although C# 8+ default interface members provide a limited form of implementation.
Syntax and Capabilities
Abstract classes can contain fields, instance constructors, destructors, and members with different access modifiers. Interfaces cannot contain instance fields or instance constructors. Classic interface members are implicitly public; C# 8 added default implementations, and some interface members can be declared with non-public access, but instance state is still not allowed.
| Capability | Abstract Class | Interface |
|---|---|---|
| Instance fields | Yes | No |
| Instance constructors | Yes | No |
| Concrete methods | Yes | Yes (C# 8+) |
| Multiple base types | One base class only | Can implement many interfaces |
| Access modifiers on members | Yes | Public by default; some non-public members allowed (C# 8+) |
| Abstract members | Yes | Yes |
Abstract classes give you more control over shared internal implementation details because they can have protected, internal, private, and virtual members. Interfaces, by contrast, are primarily a public contract.
Multiple Inheritance and Type Contracts
C# does not support multiple inheritance for classes. A class can inherit from only one base class, but it can implement any number of interfaces. This is a primary reason to choose an interface when you need to model a capability that can be applied across unrelated types.
public interface IResettable
{
void Reset();
}
public class Repository : IResettable
{
public void Reset() { /* clear cache */ }
}
public class ViewModel : IResettable
{
public void Reset() { /* clear state */ }
}Both Repository and ViewModel implement IResettable without sharing a common base class. An abstract class would force them into a single inheritance hierarchy, which is often too restrictive.
Default Implementations in Interfaces
Since C# 8.0, interfaces can provide default implementations for methods. This blurs the line between abstract classes and interfaces, but important differences remain. A default implementation allows you to add a member to an interface without requiring existing implementers to change.
public interface ILogger
{
void Log(string message);
void LogError(string message)
{
Log($"ERROR: {message}");
}
}Implementing classes that do not override LogError get the default behavior. However, default implementations cannot access instance state because interfaces still cannot contain instance fields. They can call other interface members or use static data. This limitation keeps interfaces closer to contracts than reusable implementation containers.
When to Use an Abstract Class
Use an abstract class when you have a group of closely related classes that share common logic, state, or protected members. The abstract class can provide a base implementation that derived classes extend or override. This is common in frameworks where a template method pattern is useful.
public abstract class DataProcessor
{
protected abstract void ProcessRow(string row);
public void ProcessAll(IEnumerable<string> rows)
{
foreach (var row in rows)
{
ProcessRow(row);
}
}
}
public class CsvProcessor : DataProcessor
{
protected override void ProcessRow(string row)
{
// CSV-specific logic
}
}Here, DataProcessor owns the iteration logic and forces derived classes to implement ProcessRow. This is a classic use case for an abstract class: you control the algorithm skeleton and let subclasses fill in the details.
When to Use an Interface
Use an interface when you need to define a capability that can be implemented by unrelated types. Interfaces are ideal for dependency injection, mocking, and designing against abstractions. They allow you to decouple the consumer from the concrete implementation.
public interface IMessageSender
{
void Send(string recipient, string text);
}
public class EmailSender : IMessageSender
{
public void Send(string recipient, string text) { }
}
public class SmsSender : IMessageSender
{
public void Send(string recipient, string text) { }
}A service that depends on IMessageSender can work with either sender without knowing the concrete type. This is the foundation of many design patterns, including the strategy pattern and the repository pattern.
Performance and Runtime Considerations
From a runtime perspective, interface dispatch is slightly more expensive than virtual method calls on a class, but the difference is negligible in most applications. The JIT compiler can often devirtualize calls when it can prove the concrete type. The more important cost can be boxing when a value type is converted to an interface it implements.
public interface IShape
{
double Area { get; }
}
public struct Circle : IShape
{
public double Radius { get; set; }
public double Area => Math.PI * Radius * Radius;
}When a Circle is passed as an IShape, it is boxed. If this happens frequently in a hot loop, it can create GC pressure. A generic constraint such as where T : IShape can avoid that boxing, but an abstract class cannot model value types because structs cannot inherit from classes. This is a genuine tradeoff: interfaces support structs but may box; abstract classes do not support structs at all.
Maintainability and Evolution
Without a default implementation, adding a new member to an interface is a breaking change for all implementers. Even with default implementations, existing classes that do not override the new member will use the default, which may not match their expected behavior. Adding a new virtual method to an abstract class is non-breaking because derived classes inherit the base implementation unless they override it.
This makes abstract classes more forgiving when you control the entire hierarchy and can update base logic. Interfaces are a better fit when you expect third-party implementations that you cannot update. If you need to add members to an interface over time, default implementations reduce the break, but because they cannot access instance state, the default often throws NotSupportedException or does nothing.
Combining Both Approaches
In real designs, abstract classes and interfaces often work together. A common pattern is to define an interface as the public contract, then provide an abstract base class that implements that interface with common behavior. Consumers depend on the interface, while derived classes inherit from the base class to reuse implementation.
public interface IRepository<T>
{
T GetById(int id);
void Save(T entity);
}
public abstract class RepositoryBase<T> : IRepository<T>
{
public abstract T GetById(int id);
public virtual void Save(T entity)
{
// shared validation or logging
}
}
public class CustomerRepository : RepositoryBase<Customer>
{
public override Customer GetById(int id) { /* ... */ }
}This gives you the flexibility of interface-based dependency injection and the convenience of shared implementation. The interface remains the contract for consumers; the abstract class is an implementation detail.
A Practical Decision Rule
When you are unsure which to use, ask whether the types that will implement the abstraction share a common ancestor in your domain. If they do, and you want to share code, an abstract class is often simpler. If they do not, and you only need to guarantee a set of members, an interface is the right choice. Also consider whether you need to support value types (structs): interfaces allow that, abstract classes do not. Finally, think about evolution: if you expect to add members frequently and you control all implementers, an abstract class is easier to extend; if you have external implementers, an interface with default methods is safer.
The choice is not about one being superior. It is about matching the abstraction to the constraints of your type hierarchy, the need for shared state, and the direction of change. A well-chosen abstraction reduces coupling and makes future refactoring less painful.
Try matching browser tools
All toolsSmall utilities that fit C# work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related C# guides
All C# guidesC# Dispose vs Destructor: Key Differences Explained
c# dispose vs destructor: Understand the difference between Dispose and destructors in C#, when each runs, and how to manage unmanaged resources correctly.
C# Variable Declaration: Syntax and Practical Usage
Learn how to declare variables in C# with explicit types, var, and nullable annotations, and understand how defaults, scope, and readability affect your choices.
C# Primary Constructors for Classes: Syntax and Usage
Learn how to use C# primary constructors for classes: syntax, initialization, dependency injection, and limitations with practical examples.
C# IComparer: Custom Sorting with IComparer<T>
Learn how to implement IComparer<T> in C# to define custom sort order for arrays and lists, handle nulls, and avoid common performance pitfalls.
More in C#
All C# guidesThe guides filed next to this one in C#, in library order.