Home All Groups Group Topic Archive Search About

OrderedDictionary index order

Author
25 Apr 2007 7:55 PM
Mike Blake-Knox
The OrderedDictionary method documentation says that the Add(key,
value) method stores the entry into the OrderedDictionary collection
with the lowest available index. This ensures that the oldest entry is
at index 0. The Remarks section of the OrderedDictionary.Add Method
says you can also use the
System.Collections.Specialized.OrderedDictionary.Item(System.Object)
property to add new elements by setting the value of a key that does
not exist in the OrderedDictionary collection. The Remarks section of
the OrderedDictionary.Item Property(Object) says that the
'myCollection["myNonexistentKey"] = myValue' syntax can also be used to
add an entry.

Is it safe to assume that the entry at index 0 is the oldest entry when
entries were added using the indexer syntax? This is the behavior I
observed experimentally.

Wouldn't it be nice if a class's indexer functionality was documented
in a consistent place?

Thanks

Mike

AddThis Social Bookmark Button