Interfaces — RexDac Academy

RexDac AcademyTechnical notes · Some prior knowledge helps
0%Published notes read · this device

Level 5 — Inheritance

Interfaces

Original notes by SunDiaL · View English source

Interfaces are... a weird thing.
Conceptually, interfaces represent a contract or capability. An interface says: "Any class that implements me must have these members." Functionally, they're like a purely abstract class — they define members without implementations — but they come with some key differences:

  • interfaces support multiple inheritance. (since they represent contracts) all interface members are public and must be implemented as public

A class doesn't inherit an interface — it implements it.

interface IDriveable {
    void Drive();
}

class Car : IDriveable {
    public void Drive() {
        Console.WriteLine("Vroom!");
    }
}