title: Is there a way to declare a variable that implements multiple interfaces in .Net?
body: <p>Similar to <a href="https://stackoverflow.com/questions/1121829/">this Java question</a>. I would like to specify that a variable implements multiple interfaces. For instance</p>
  
  <pre><code>private {IFirstInterface, ISecondInterface} _foo;
  
  public void SetFoo({IFirstInterface, ISecondInterface} value)
  {
      _foo = value;
  }
  </code></pre>
  
  <p>Requirements:</p>
  
  <ul>
  <li>I don't have the ability to add an interface to most type that would be passed in to Foo. So I can't create a third interface that inherits from IFirstInterface and ISecondInterface.</li>
  <li>I would like to avoid making the containing class generic if possible because the type of Foo doesn't have much to do with the class and the user isn't likely to know it at compile time.</li>
  <li>I need to use foo to access methods in both interfaces at a later time.</li>
  <li>I would like to do this in a compiler safe way, i.e. no trying to cast to the interface just before trying to use it. If foo does not implement both interfaces quite a bit of functionality won't work properly.</li>
  </ul>
  
  <p>Is this possible?</p>
  
  <p><strong>Edit</strong>: I've wanted this a few times for various reasons. In this instance it's because I am changing a set of properties from ObservableCollections to ReadOnlyObservableCollections. I have a helper class that creates a projection from a source ObservableCollection to another Collection. Since ReadOnlyObservableCollection does not inherit from ObservableCollection and I only need operations in IList and INotifyCollectionChanged I was hoping to store my source collection as a combination of these two interfaces rather than requiring an ObservableCollection.</p>