Junior From PDF OOP C# OOP

What is the Dependency Inversion Principle and how do interfaces support it?

  • High-level modules should not depend on low-level modules. Both should depend

on abstractions.

  • Interfaces allow decoupling and easier testing.
interface ILogger { void Log(string message); }
class FileLogger : ILogger { public void Log(string message) =>

Console.WriteLine("File: " + message); }

class UserService
{
private readonly ILogger _logger;
public UserService(ILogger logger) { _logger = logger; }
}

More from C# Programming Tutorial

All questions for this course
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details