Get and set the value associated with a specific key in a SortedList in CSharp

Description

The following code shows how to get and set the value associated with a specific key in a SortedList.

Example


//  w  ww.ja  va2  s  . com
using System;
using System.Collections;
public class SamplesSortedList  {
   public static void Main()  {
    SortedList mySortedList = new SortedList();
    mySortedList[2] =  "two";
      
    foreach (string myKey in mySortedList.Keys)
    {
      Console.WriteLine("myKey = " + myKey);
    }

    foreach(string myValue in mySortedList.Values)
    {
      Console.WriteLine("myValue = " + myValue);
    }      

   }
}




















Home »
  C# Tutorial »
    Collections »




ArrayList
BitArray
Collection
Comparer
HashSet
Hashtable
LinkedList
List
ListDictionary
OrderedDictionary
Queue
SortedList
SortedSet
Stack
StringCollection
StringDictionary