From the course: C#: Applied Data Structures
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
OrderedDictionary
From the course: C#: Applied Data Structures
OrderedDictionary
- [Instructor] With regular dictionaries, there is usually no guarantee that the collection will maintain the order in which items are added to the data structure. Most of the time this isn't important. But occasionally there'll be scenarios in which you want to process dictionary elements in the order in which they were added. For this scenario, you can use the OrderedDictionary. So let's go ahead and open up our example. So let's jump straight to the code. And here in my source, I have created an OrderedDictionary, which is also available in the specialized collections module. You can see that I've got that up here. Alright, let's scroll down a little bit. So let's go ahead and add some items to the dictionary in a particular order. So I'm going to add item one, and I'll give that a value one. And then I'll just make a few, oops, make a few copies of this and we'll just go ahead and make item two, three, and four.…