This is the most
commonly used Dependency Pattern. The Constructor Injection uses a parameter to
inject dependencies. Generally, there is normally one parameterized constructor
always. So in this case, the object has no default constructor and we need to
pass specified values or dependency at the time of initiation the object.
We will go through one
example for better understanding of this type of dependency injection.
IBook.cs
Book.cs
Library.cs
Program.cs
Here,the Injection happens in the
constructor, by passing the Service that implements the IBook Interface.