Mid From PDF MNC Coding C# MNC Coding Interview

Dependency Injection without any framework?

Dependency Injection without any framework

What interviewers test

  • SOLID
  • Architecture fundamentals

Step 1: Abstraction

public interface IMessageService
{

void Send(string message);

}

Step 2: Implementation

public class EmailService : IMessageService
{
public void Send(string message)
{

Console.WriteLine("Email: " + message);

}
}

Step 3: Injection

public class Notification
{
private readonly IMessageService _service;
public Notification(IMessageService service)
{
_service = service;
}
public void Notify(string msg)
{

_service.Send(msg);

}
}

Why this matters

  • Loose coupling
  • Testable code
  • Swappable implementations

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