title: ASP .Net Core Web APIs Dependency Injection Class with Multiple Constructors
body: <p>I am using Asp .net core 2.2 with built-in DI. I want to inject service that has multiple constructors that fulfill the container conditions. And I can't remove the other constructor for backward compatibility. Example code:</p>
  
  <pre><code>public interface IService{
     void DoSomthing();
  }
  
  public class Implementation : IService
  {
      public Implementation(IService1 service1)
      {
  
      }
  
      public Implementation(IService1 service1, IService2 service2)
      {
  
      }
  
      public void DoSomthing()
      {
          // Do something
      }
  }
  </code></pre>
  
  <p>I registered all these services in the DI container example:</p>
  
  <pre><code>services.AddScoped&lt;IService, Implementation&gt;();
  </code></pre>
  
  <p>Now I have another class that uses IService as DI:</p>
  
  <pre><code>public class ClassA : IService
  {
      public ClassA(IService service)
      {
  
      }
  }
  </code></pre>
  
  <p>How Dependency injection container will intialize this class using which constructor?:</p>
  
  <pre><code>public Implementation(IService1 service1)
  Or
  public Implementation(IService1 service1, IService2 service2)
  </code></pre>
  
  <p>and what is the rule for choosing between them?</p>