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# | Get a read-only copy of the OrderedDictionary
- C# | Get the number of key/values pairs contained in OrderedDictionary
- C# | Get an ICollection containing values in OrderedDictionary
- C# | Get an ICollection containing keys in OrderedDictionary
- C# | Add key and value into OrderedDictionary collection
- C# | Check if OrderedDictionary collection contains a specific key
- C# | Check if OrderedDictionary collection is read-only
- C# | OrderedDictionary Class
- C# | Remove all elements from OrderedDictionary
- C# | Remove entry with specified key from OrderedDictionary
- C# | Insert into OrderedDictionary with key and value at specified index
- C# | Remove the entry at specified index from OrderedDictionary
- C# | Copy OrderedDictionary elements to Array instance at the specified index
- C# | Insert a new entry in OrderedDictionary with specified key and value
- C# | Check if two OrderedDictionary objects are equal
- How to create an OrderedDictionary in C#
- C# | Check if an array object is equal to another array object
- C# | Get object at the top of the Stack - Peek operation
- C# | Get the object at the beginning of the Queue - Peek Operation
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.