title: Is it possible to define a list of any type that implements multiple interfaces?
body: <p>Consider the following class hierarchy:</p>
  
  <pre><code>public interface X { void Foo(); }
  
  public interface Y { void Bar(); }
  
  public class A : X, Y
  {
      public void Foo() {}
      public void Bar() {}
  }
  
  public class B : X, Y
  {
      public void Foo() {}
      public void Bar() {}
  }
  </code></pre>
  
  <p>Is there any way I can define a list (or any generic type for that matter) which can contain both <code>A</code>'s and <code>B</code>'s, while allowing me to treat the contents of said list as both <code>X</code> and <code>Y</code>? I.e. something that will allow me to write something along the lines of this:</p>
  
  <pre><code>var list = ???
  list.Add(new A());
  list.Add(new B());
  list.First().Foo();
  list.Last().Bar();
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>Just to clarify, the types I'm currently dealing with are <a href="http://msdn.microsoft.com/en-us/library/ms668604%28v=vs.110%29.aspx"><code>ObservableCollection&lt;T&gt;</code></a> (<code>A</code>) and <a href="http://msdn.microsoft.com/en-us/library/ms668620%28v=vs.110%29.aspx"><code>ReadOnlyObservableCollection&lt;T&gt;</code></a> (<code>B</code>), where the interfaces I'm interested in are <code>IList&lt;T&gt;</code> (<code>X</code>) and <code>INotifyCollectionChanged</code> (<code>Y</code>). Clearly I'm unable to change their class hierarchy to accomodate my needs, so I need a different workaround.</p>