title: Can I use a dependency injection singleton in two different classes?
body: <p>I have an interface:</p>
  <pre><code>public interface Irepos 
  {
      string somefunction();
  }
  </code></pre>
  <p>Then the class I want to use:</p>
  <pre><code>public class repos : Irepos
  {
      string somefunction()
      {
          return &quot;function called&quot;;
      }
  }
  </code></pre>
  <p>Registered as singleton in startup.cs:</p>
  <pre><code>services.AddSingleton&lt;Irepos, repos&gt;();
  </code></pre>
  <p>Now I can use it like this in my controller class:</p>
  <pre><code>public class controller 
  {
      private readonly Irepos interfaceRepos;
      
      public ValuesController(Irepos reposInerface)
      {
          interfaceRepos = reposInerface;
      }
  
      interfaceRepos.somefunction();
  }
  </code></pre>
  <p>Now my question is: can I use the same instance of the same <code>repos</code> class in a different class or different controller? Say:</p>
  <pre><code>public class AnotherController
  {
      private readonly Irepos interfaceRepos;
          
      public ValuesController(Irepos reposInerface)
      {
          interfaceRepos = reposInerface;
      }
      
      interfaceRepos.somefunction();
  }
  </code></pre>