C# | Multiple inheritance using interfaces

Last Updated : 3 Feb, 2026

Multiple inheritance means a class can inherit features from more than one base class. While this is supported in some languages, C# does not allow multiple inheritance with classes to avoid ambiguity and complexity (such as the diamond problem).

However, C# supports multiple inheritance through interfaces. A class can implement multiple interfaces and thereby acquire behavior from multiple sources.

multiple-inheritance
Illustration of Multiple Inheritance

Interface in C#

An interface is a contract that defines:

  • Method signatures
  • Properties
  • Events
  • Indexers

A class that implements an interface must provide implementations for all its members. A class can implement multiple interfaces, which enables multiple inheritance-like behavior.

Implementing Multiple Inheritance Using Interfaces

A class implements interfaces by listing them after the class name, separated by commas. The class must then provide implementations for all interface members.

Syntax:

class ClassName : IInterface1, IInterface2
{
// implement all interface methods here
}

This allows a single class to support multiple behaviors defined by different interfaces.

Example: In this example, a class implements two interfaces and provides implementations for both.

C#
using System;

interface IShape
{
    double GetArea();
}

interface IColor
{
    string GetColor();
}

class Rectangle : IShape, IColor
{
    private double length;
    private double breadth;
    private string color;

    public Rectangle(double length, double breadth, string color)
    {
        this.length = length;
        this.breadth = breadth;
        this.color = color;
    }

    public double GetArea()
    {
        return length * breadth;
    }

    public string GetColor()
    {
        return color;
    }
}

class Program
{
    static void Main()
    {
        Rectangle rect = new Rectangle(5, 10, "Blue");

        Console.WriteLine("Area: " + rect.GetArea());
        Console.WriteLine("Color: " + rect.GetColor());
    }
}

Output
Area: 50
Color: Blue

Explanation:

  • IShape and IColor are two separate interfaces defining different behaviors.
  • Each interface declares one method without implementation.
  • Rectangle implements both interfaces using : IShape, IColor.
  • The class must provide implementations for both GetArea() and GetColor().
  • Constructor initializes the rectangle’s dimensions and color.
  • In Main(), the object calls both interface methods normally.

Implementing Multiple Interfaces with Delegation

A class implementing multiple interfaces does not need to implement all logic directly. It can delegate the implementation to helper classes while still fulfilling the interface contracts.

C#
using System;
using System.Collections;

interface ILanguageProvider
{
    void ShowLanguages();
}

interface ICourseProvider
{
    void ShowCourses();
}

class LanguageService : ILanguageProvider
{
    public void ShowLanguages()
    {
        ArrayList list = new ArrayList()
        {
            "C", "C++", "C#", "Java"
        };

        Console.WriteLine("Languages:");
        foreach (var item in list)
            Console.WriteLine(item);
    }
}

class CourseService : ICourseProvider
{
    public void ShowCourses()
    {
        ArrayList list = new ArrayList()
        {
            "System Design",
            "Python",
            "DSA",
            "Java"
        };

        Console.WriteLine("\nCourses:");
        foreach (var item in list)
            Console.WriteLine(item);
    }
}

class Portal : ILanguageProvider, ICourseProvider
{
    LanguageService lang = new LanguageService();
    CourseService course = new CourseService();

    public void ShowLanguages() => lang.ShowLanguages();
    public void ShowCourses() => course.ShowCourses();
}

class Program
{
    static void Main()
    {
        Portal p = new Portal();
        p.ShowLanguages();
        p.ShowCourses();
    }
}

Output
Languages:
C
C++
C#
Java

Courses:
System Design
Python
DSA
Java

Explanation:

  • Two interfaces define two independent capabilities: language listing and course listing.
  • LanguageService implements ILanguageProvider.
  • CourseService implements ICourseProvider.
  • Portal implements both interfaces.
  • Instead of writing logic again, Portal delegates calls to helper objects.
  • This pattern improves reuse and separation of concerns.
  • The caller only interacts with the Portal class while multiple behaviors are supported.

Key Rules for Multiple Inheritance via Interfaces

  • A class can implement multiple interfaces
  • Interfaces cannot contain instance fields
  • All interface members must be implemented
  • Interface methods are public by default
  • Multiple interfaces can define the same method name (explicit implementation may be required)
Comment

Explore