views:

21

answers:

1
+2  Q: 

List with a key

Before I embark on writing my own, is there a List like construct that also contains a Dictionary like key?

And before someone suggests using a Dictionary instead, the order of items is important to me and Dictionary cannot guarantee a position.

So, I'd like to be able to retrieve the item in the following manner:

int position = 4;
MyObject o = MyCollection[position];

and like this:

string key = "MyKey";
MyObject o = MyCollection[key];

Is there some such thing?

+2  A: 

I believe that you can use the Ordered Dictionary class for this.

In fact, yes. Yes you can.

John Gietzen
Non-generic. Feels dirty. But it'll probably do.
AngryHacker