OrderedDictionary.GetEnumerator method returns an IDictionaryEnumerator object that iterates through the OrderedDictionary collection.
public virtual System.Collections.IDictionaryEnumerator GetEnumerator ();
Return Value: An IDictionaryEnumerator object for the OrderedDictionary collection.
Below given are some examples to understand the implementation in a better way:
key1 --> value1 key2 --> value2 key3 --> value3 key4 --> value4 key5 --> value5
A --> Apple B --> Banana C --> Cat D --> Dog
- Enumerators can be used to read the data in the collection, but they cannot be used to modify the underlying collection.
- Initially, the enumerator is positioned before the first element in the collection.
- This method is an O(1) operation.
- An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably invalidated and its behavior is undefined.
- C# | OrderedDictionary.Item[Object] Property
- C# | OrderedDictionary Class
- How to create an OrderedDictionary in C#
- C# | Add key and value into OrderedDictionary collection
- C# | Insert into OrderedDictionary with key and value at specified index
- C# | Get an ICollection containing keys in OrderedDictionary
- C# | Get an ICollection containing values in OrderedDictionary
- C# | Remove entry with specified key from OrderedDictionary
- C# | Remove all elements from OrderedDictionary
- C# | Get a read-only copy of the OrderedDictionary
- C# | Insert a new entry in OrderedDictionary with specified key and value
- C# | Check if two OrderedDictionary objects are equal
- C# | Check if OrderedDictionary collection is read-only
- C# | Check if OrderedDictionary collection contains a specific key
- C# | Remove the entry at specified index from OrderedDictionary
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.