cipher = new Dictionary<char,int>;
cipher.Add( 'a', 324 );
cipher.Add( 'b', 553 );
cipher.Add( 'c', 915 );
How to get the 2nd element? For example, I'd like something like:
KeyValuePair pair = cipher[1]
where pair contains ( 'b', 553 )
thanks!
Based on thecoop's suggestion using a List, things are workking:
List<KeyValuePair<char, int>> cipher = new List<KeyValuePair<char, int>>();
cipher.Add( new KeyValuePair<char, int>( 'a', 324 ) );
cipher.Add( new KeyValuePair<char, int>( 'b', 553 ) );
cipher.Add( new KeyValuePair<char, int>( 'c', 915 ) );
KeyValuePair<char, int> pair = cipher[ 1 ];
Assuming that I'm correct that the items stay in the list in the order that they are added, I belive that I can just use a List as opposed to a SortedList as suggested.
thanks!