Is there an alternative to a dictionary in .NET?

I have a requirement to use a dictionary in a project, but, as we know, they are accessible only with keys and do not use indexes, and I want to access elements in a dictionary using indexes. So I fiddled around the net and found out about OrderedDictionary, since they are accessible using indexes and keys, but they have a performance problem, and when I read / write a dictionary every minute of the day, it’s nice to use OrderedDictionary.

So my question here is that there is some alternative that gives me the functionality of a dictionary, and I can also access it using indexes and not cause performance issues.

+4
source share
3 answers

in response to your comment that you only expect hundreds of updates per minute, this is very little work - almost nothing. You can still use OrderedDictionary , performance will not be a problem for you.

+3
source

SortedList<TKey, TValue> has the Values property, that is, IList<TValue> . This is enough? This is fast only for small "sets" of items. The difference with SortedDictionary here http://msdn.microsoft.com/en-us/library/5z658b67(v=vs.80).aspx

May I ask you why you want to access it "by index"? You can still list it using foreach, you know?

+6
source

All Articles