Create SortedList with specified initial capacity, in CSharp
Description
The following code shows how to create SortedList with specified initial capacity,.
Example
using System;//from ww w . j a v a2 s. co m
using System.Collections;
using System.Globalization;
public class SamplesSortedList
{
public static void Main()
{
SortedList mySL1 = new SortedList( 3 );
Console.WriteLine("mySL1 (default):");
mySL1.Add("FIRST", "Hello");
mySL1.Add("SECOND", "World");
mySL1.Add("THIRD", "!");
mySL1.Add("first", "Ola!");
Console.WriteLine(" -KEY- -VALUE-");
for (int i = 0; i < mySL1.Count; i++)
{
Console.WriteLine("{0,-6}: {1}",mySL1.GetKey(i), mySL1.GetByIndex(i));
}
}
}
The code above generates the following result.