I have some problems in display the dictionary, as example in below:

  SortedList mySL = new SortedList();
  Console.WriteLine( "\t-KEY-\t-VALUE-" );
  for ( int i = 0; i < myList.Count; i++ )  {
     Console.WriteLine( "\t{0}:\t{1}", mySL.GetKey(i), mySL.GetByIndex(i) );
  }

For the codes in above,"myList.GetKey(i), myList.GetByIndex(i)" just can work if mySL is SortedList. How about if mySL is a Dictionary as below? How to display it in same situation in program above?

Dictionary<string,double> mySL =new Dictionary<string,double>();
Console.WriteLine("\t{0}:\t{1}", mySL.Keys[i], mySL.Values[i]);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.