title: How to define the default implementation of an interface in c#?
body: <p>There is some black magic code in c# where you can define the default implementation of an interface.</p>
  
  <p>So you can write</p>
  
  <pre><code>var instance = new ISomeInterface();
  </code></pre>
  
  <p>Any pointers?</p>
  
  <p>UPDATE 1: Note that I did not ask if this is a good idea. Just how was it possible to do it.</p>
  
  <p><strong>UPDATE 2: to anyone seeing the accepted answer.</strong></p>
  
  <ul>
  <li>"this should be treated merely as a curiosity." from Marc Gravel <a href="https://stackoverflow.com/questions/1303717/newing-up-interfaces">&quot;Newing up&quot; Interfaces</a> </li>
  <li>"It's a bad idea to use a tool designed for COM interop to do something completely and utterly different. That makes your code impossible to understand for the next guy who has to maintain it" from Eric Lippert <a href="https://stackoverflow.com/questions/1303717/newing-up-interfaces">&quot;Newing up&quot; Interfaces</a> </li>
  <li>"While it may work, if it were ever found in production code by a rational coder, it would be refactored to use a base class or dependency injection instead." from Stephen Cleary in a comment below.</li>
  </ul>