← Back to C# Course | Chapter 8: Interfaces | Lesson 3 of 6

Multiple Interfaces

In this page:

  1. Multiple Interfaces

Multiple Interfaces

Unlike class inheritance, a class can implement any number of interfaces at once, separated by commas. This lets a single type satisfy several unrelated contracts simultaneously. It's C#'s way of achieving multiple-inheritance-like behavior safely.

Note: Use several small, focused interfaces rather than one large one — it's easier for classes to mix and match.

Example: Multiple Interfaces

markup
using System;

interface IFlyable
{
    void Fly();
}

interface ISwimmable
{
    void Swim();
}

class Duck : IFlyable, ISwimmable
{
    public void Fly() => Console.WriteLine("Duck is flying");
    public void Swim() => Console.WriteLine("Duck is swimming");
}

class Program
{
    static void Main(string[] args)
    {
        Duck d = new Duck();
        d.Fly();
        d.Swim();
    }
}
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.