I want an indexed list by ID, ordered by a special attribute inside my class.
SortedList, doesnt do this, because it forces me to sort by the key…
Lets say my class is
class example{
int Id;
int Order
}
Is there any structure that is indexed like a dictionary, and ordered by something else?
so that I can access data by ID, but in a foreach the data is ordered by Order
As far as I know, there is no
Dictionarytype object that will give you that behavior right out of the box.If you are only worried about accessing in a specified order in a
foreachloop then why not useLINQ?Yes you will pay a penalty in performance, but if it is not an issue this is, IMHO, the easiest way to get what you want.