Roadmap › OOP Concepts in C# › Module: The Four Pillars
Lessons in this course (15)

6. Abstraction

Basic★ Must knowLesson 6 of 15

Abstraction = expose only what callers need and hide implementation details. In C# you abstract with interfaces and abstract classes.

csharp
public interface IPaymentGateway
{
    Task<PaymentResult> ChargeAsync(decimal amount, string currency, string token);
}

public class RazorpayGateway : IPaymentGateway { /* HTTP calls, signatures, retries hidden here */ }
public class StripeGateway : IPaymentGateway { /* ... */ }

public class CheckoutService(IPaymentGateway gateway)     // depends on the abstraction only
{
    public Task<PaymentResult> Pay(Order o) => gateway.ChargeAsync(o.Total, "INR", o.CardToken);
}

Interview tip: encapsulation is about hiding data (how state is protected); abstraction is about hiding complexity (what is exposed). They work together.