Thuta Learning
AdvancedProgrammingbeginner

Interfaces

Relax. We'll talk through this in plain words — no textbook voice.

Interface is a contract that spells out which methods/properties a class must have. Any class that implements the interface has to provide all the members defined inside it.

csharp
interface INotification
{
    void Send(string message);
}

class EmailNotification : INotification
{
    public void Send(string message)
    {
        Console.WriteLine($"Email sent: {message}");
    }
}

class SmsNotification : INotification
{
    public void Send(string message)
    {
        Console.WriteLine($"SMS sent: {message}");
    }
}

class Program
{
    static void Main(string[] args)
    {
        INotification notifier = new EmailNotification();
        notifier.Send("Welcome to ThutaTech");
    }
}

Where interfaces come in handy

You can send a notification through email, SMS, push notification, or whatever else — but your app's main logic only needs to know about one Send() method. Want to change the implementation? Just swap out the class.

You should see
Email sent: Welcome to ThutaTech
Interfaces | Thuta Learning