title: How to know if an enumerator has reached the end of the collection in C#?
body: <p>I am porting a library from C++ to C#. The old library uses vectors from C++ and in the C# I am using generic Dictionaries because they're actually a good data structure for what I'm doing (each element has an ID, then I just use using <code>TypeDictionary = Dictionary&lt;String, Type&gt;;</code>). Now, in the C# code I use a loop like this one</p>
  
  <pre><code>TypeDictionary.Enumerator tdEnum = MyTypeDictionary.GetEnumerator();
  
  while( tdEnum.MoveNext() ) 
  {
     Type element = typeElement.Current.Value;
  
     // More code here
  }
  </code></pre>
  
  <p>to iterate through the elements of the collection. The problem is that in particular cases I need to check if a certain enumerator has reached the end of the collection, in C++ I would have done a check like this:</p>
  
  <pre><code>if ( tdEnum == MyTypeDictionary.end() ) // More code here
  </code></pre>
  
  <p>But I just don't know how to handle this situation in C#, any ideas?</p>
  
  <p>Thank you<br />
  Tommaso</p>