title: ReadOnlyCollection or IEnumerable for exposing member collections?
body: <p>Is there any reason to expose an internal collection as a ReadOnlyCollection rather than an IEnumerable if the calling code only iterates over the collection?</p>
  
  <pre><code>class Bar
  {
      private ICollection&lt;Foo&gt; foos;
  
      // Which one is to be preferred?
      public IEnumerable&lt;Foo&gt; Foos { ... }
      public ReadOnlyCollection&lt;Foo&gt; Foos { ... }
  }
  
  
  // Calling code:
  
  foreach (var f in bar.Foos)
      DoSomething(f);
  </code></pre>
  
  <p>As I see it IEnumerable is a subset of the interface of ReadOnlyCollection and it does not allow the user to modify the collection. So if the IEnumberable interface is enough then that is the one to use. Is that a proper way of reasoning about it or am I missing something?</p>
  
  <p>Thanks /Erik</p>