title: Why I should not modify a collection when I am iterating on it
body: <p>I know that in .net collection types (or at least some collection types) do not allow modify the collection when you are iterating on it. </p>
  
  <p>For example in the List class exist a code like this:</p>
  
  <pre><code>if (this.version != this.list._version)
   ThrowHelper.ThrowInvalidOperationException(ExceptionResource.InvalidOperation_EnumFailedVersion);
  </code></pre>
  
  <p>But obviously this is a decision of the developers that design the iterator class, because I can provide some implementations of <code>IEnumerable</code> that at least do not throw any Exception when the under-laying collection is modified.</p>
  
  <p>Then I have some questions:</p>
  
  <ul>
  <li><p>Why I should not modify a collection when I am iterating on it ?</p></li>
  <li><p>It is possible to create a collection that support to be modified when iterating on it, without to have any other problems ? (NOTE: that the first answer can answer this one too)</p></li>
  <li><p>When the C# compiler generate the <code>Enumerator</code> interface implementation takes into account this such of things?</p></li>
  </ul>