Dependency Injection in C#

CsharpProgrammingServer Side Programming

The concept of Dependency Injection in C# introduced to enable the development of loosely coupled code. Loosely coupled code and be easily maintained and reused.

The following are the types of Dependency Injection in C#.

Constructor Injection

To inject dependencies, the constructor injection uses parameters. It is useful when a class needs one or more dependencies.

Setter Injection

Check for null before using the Setter Injection. It allows to create resources and services as required.

Method Injection

This type of injection injects the dependency into a single method, which is to be utilized by that method.

raja
Published on 17-Sep-2018 17:31:58
Advertisements