title: Why can't type inference determine type from constraints
body: <p>I have made an interface so that I can try and make some repeated code generic.</p>
  
  <pre><code>public interface IIdentifiable&lt;T&gt;
  {
      T Id { get; set; }
  }
  </code></pre>
  
  <p>Then I have a class that works with an entity, with the constraint of <code>IIdentifiable&lt;T&gt;</code></p>
  
  <pre><code>public class MyClass&lt;TEntity, TId&gt;
      where TEntity : IIdentifiable&lt;TId&gt; {}
  </code></pre>
  
  <p>But now whenever I use <code>MyClass</code> I have to pass in <code>TId</code> even though there is only one valid type for <code>TId</code>.</p>
  
  <pre><code>public class MyEntity : IIdentifiable&lt;Guid&gt; {}
  
  var foo = new MyClass&lt;MyEntity&gt;(); // Error
  var bar = new MyClass&lt;MyEntity, Guid&gt;();
  </code></pre>
  
  <p>In C++ I can do this:</p>
  
  <pre><code>template&lt;typename T&gt;
  struct IIdentifiable
  {
      using id_type = T;
  
      T id;
  };
  
  template&lt;typename TEntity, typename TId = typename TEntity::id_type&gt;
  struct MyClass {};
  
  MyClass&lt;MyEntity&gt; foo;
  </code></pre>
  
  <p>Is there a C# equivalent?</p>