title: Casting an object to two interfaces at the same time, to call a generic method
body: <p>I want to call a generic method that constrains the input type T to implement two interfaces:</p>
  
  <pre><code>interface IA { }
  interface IB { }
  void foo&lt;T&gt;(T t) where T : IA, IB { }
  </code></pre>
  
  <p>How can I fix the last line of </p>
  
  <pre><code>void bar(object obj)
  {
      if (obj is IA &amp;&amp; obj is IB)
      {
          foo((IA &amp;&amp; IB)obj);
      }
  }
  </code></pre>
  
  <p>?</p>
  
  <p>Reflection probably allows to do the call, but I would like to stay within the language.</p>