I have the following Dictionary content :
[0] {75, SimpleObject}
[1] {56, SimpleObject}
[2] {65, SimpleObject}
[3] {12, SimpleObject}
...
I want to get first key, means 75, without foreach.
Maybe the key word should reffers to [0] not 75.
Because based on that key, I want to use that SimpleObject, I wrote:
SimpleObject s = dictionary[0] as SimpleObject;
but the VS2010 throws an exception:
The given key was not present in the dictionary.
I know that [0] means key number 0 from dictionary, means if I could have
[0] {72, SimpleObject} //here
[1] {56, SimpleObject}
[2] {65, SimpleObject}
[3] {12, SimpleObject}
...
then I should get the correspondent SimpleObject.
Sorry, is first time using Dictionary and I want to learn more.
Question: How to get the number 75 and his SimpleObject ?
Thank you.
PS: I know that in StackOverflow already exists similar topic but no of them help me to get that key.
1 Answer