static void Main() { SortedListSS lista = new SortedListSS(); lista.Add("hola", "hello"); lista.Add("uno", "one"); lista.Add("dos", "two"); Console.WriteLine("Contains \"uno\": " + lista.Contains("uno")); Console.WriteLine("Contains \"tres\": " + lista.Contains("tres")); Console.WriteLine("Valor de \"hola\": " + lista.GetByKey("hola")); try { Console.WriteLine(lista.GetByKey("tres")); } catch (Exception e) { Console.WriteLine(e.Message); } for (int i = 0; i < lista.Count; i++) { Console.WriteLine("Clave: " + lista.GetKey(i) + ", Valor: " + lista.GetValue(i)); } }
static void Main() { SortedListSS s = new SortedListSS(); s.Add("Naranja", "Fruta"); s.Add("Pimiento", "Verdura"); s.Add("Cacahuete", "Fruto seco"); if (s.Contains("Naranja")) { Console.WriteLine("Contiene Naranja con el valor: " + s.GetByKey("Naranja")); } else { Console.WriteLine("No contiene Naranja"); } if (s.Contains("Mesa")) { Console.WriteLine("Contiene Mesa con el valor: " + s.GetByKey("Mesa")); } else { Console.WriteLine("No contiene Mesa"); } Console.WriteLine(); Console.WriteLine("Contenido: "); for (int i = 0; i < s.Count; i++) { Console.WriteLine(s.GetKey(i) + " -> " + s.GetValue(i)); } }
static void Main() { SortedListSS myList = new SortedListSS(); myList.Add("hello", "bye"); myList.Add("sugar", "salt"); myList.Add("sea", "mountain"); Console.WriteLine(myList.GetByKey("sugar")); for (int i = 0; i < myList.Count; i++) { Console.WriteLine(myList.GetKey(i)); Console.WriteLine(myList.GetValue(i)); } }
static void Main() { SortedListSS lista = new SortedListSS(); lista.Add("uno", "dos"); lista.Add("antes", "despues"); lista.Add("mesa", "silla"); Console.WriteLine("uno? " + lista.Contains("uno")); Console.WriteLine("diez? " + lista.Contains("diez")); Console.WriteLine("uno = " + lista.GetByKey("uno")); for (int i = 0; i < lista.Count; i++) { Console.WriteLine(lista.GetKey(i) + " -> " + lista.GetValue(i)); } }
public static void Main() { SortedListSS sortedList = new SortedListSS(); sortedList.Add("zzz", "ZZZZZZ"); sortedList.Add("hola", "hello"); sortedList.Add("adios", "good bye"); sortedList.Add("que tal", "how are you"); Console.WriteLine(sortedList.Contains("hola")); Console.WriteLine(sortedList.Contains("xxx")); Console.WriteLine("---------------"); Console.WriteLine(sortedList.GetByKey("adios")); Console.WriteLine("---------------"); for (int i = 0; i < sortedList.Count; i++) { Console.WriteLine(sortedList.GetKey(i) + " - " + sortedList.GetValue(i)); } }