Delete element in a SortedList with RemoveAt
using System;
using System.Collections;
public class MainClass {
public static void Main() {
SortedList list = new SortedList();
list.Add("G", "B");
list.Add("Ae", "Sm");
list.Add("Ay", "G");
list.Add("Ab", "S");
list.Add("W", "C");
list.Remove("Abraxus");
list.RemoveAt(2);
String artist = (string)list["Ay"];
Console.WriteLine(artist);
String error = (string)list["S"];
Console.WriteLine(error);
foreach (DictionaryEntry d in list) {
Console.WriteLine("{0}, {1}", d.Key, d.Value);
}
}
}
Related examples in the same category