O'Reilly logo

Microsoft® Visual C#® 2008 Step by Step by John Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The SortedList Collection Class

The SortedList class is very similar to the Hashtable class in that it enables you to associate keys with values. The main difference is that the keys array is always sorted. (It is called a SortedList, after all.)

When you insert a key/value pair into a SortedList, the key is inserted into the keys array at the correct index to keep the keys array sorted. The value is then inserted into the values array at the same index. The SortedList class automatically ensures that keys and values are kept synchronized, even when you add and remove elements. This means that you can insert key/value pairs into a SortedList in any sequence; they are always sorted based on the value of the keys.

Like the Hashtable class, a SortedList ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required