Dependency Injection in C#
Dependency Injection is a Software Design Pattern for make Loosely coupled code.There are 3 main ways to implement dependency injection.They are Constructor Injection Property Injection Method Injection 1.Constructor Injection It uses only one Parameterized constructor. (e.g) 1. using System; interface ICar { void ShowColor(); } class Maruthi:ICar { public void ShowColor() { Console.WriteLine("Maruthi Car"); } } class ConstructorInjection { private Maruthi _maruthi; public ConstructorInjection(Maruthi m) { _maruthi=m; } public void ShowColor() { _maruthi.ShowColor(); } } public class Program { public static void Main() { ConstructorInjection cn = new ConstructorInjection(new Maruthi()); cn.ShowColor(); } } 2. public...