title: C# generic typing with multiple class constraints
body: <p><strong>TL;DR</strong> </p>
  
  <p>I'd like this to compile in C#</p>
  
  <p><code>public void some_method&lt; T &gt;() where T : class1, class2</code></p>
  
  <p>Is this possible?</p>
  
  <hr>
  
  <p><strong>Full Context</strong></p>
  
  <p>I have two methods that are identical except for <strong>one</strong> parameter.</p>
  
  <pre><code>public SignInResponseMessage Generate(SignInRequestMessage request, (X509Certificate2 || WindowsPrincipal) principal, Uri requestUri)
  {
      SignInResponseMessage response = null;
      ClaimsIdentity identity = null;
  
      if (principal != null)
      {
          identity = CreateSubject(principal);
          response = Generate(request, requestUri, identity);
      }
      else
      {
          throw new ArgumentNullException("principal");
      }
  
      return response;
  }
  </code></pre>
  
  <p>I'm currently replicating this method and it's making me cringe a little inside as I would really like to make this <code>DRY</code>-er. Looking around, <a href="https://msdn.microsoft.com/en-us/library/d5x73970.aspx?f=255&amp;MSPPError=-2147217396#Anchor_0" rel="noreferrer">this documentation</a> seemed promising, but it only allows me to add a single class constraint. I get the following error on the second class:</p>
  
  <blockquote>
    <p>Error 1   The class type constraint 'class2' must come before any other constraints</p>
  </blockquote>
  
  <p>If <code>WindowsPrincipal</code> and <code>X509Certificate2</code> were two classes I had written I could easily make them implement the same interface and I would be good to go, but that's not an option.</p>
  
  <p><strong>Is there any way to accomplish what I'd like to do?</strong></p>
  
  <p>If not, <strong>I'd like to know more about the underlying mechanism that makes this impossible</strong>.</p>