views:

213

answers:

1

Why does the Add method on the NameObjectCollectionBase insert at index position 0? Is there a way to insert the new item at the end of the collection?

I'm facing this problem in .Net 2.0

I'm not allowed to change the collection.

A: 

NameObjectCollectionBase is based on a Hashtable/Dictionary, hence it is 'unsorted' by nature.

I think you are looking for a SortedList.

Update: If you cannot change the class, you are out of luck. Just remember after each add/insert the 'positions' may change.

leppie