I want to implement dependency injection (DI) in ASP.NET Core. So after adding this code to ConfigureServices
method, both ways work.<
Normally the code request should be made through a constructor parameter, as in
public MyConsumingClass(IDependency dependency)
I wanted to point out in @akazemis's answer that "services" in the context of DI does not imply RESTful services; services are implementations of dependencies that provide functionality.