static void Main(string[] args) { Slownik <int, string> Dict = new Slownik <int, string>(); Dict.Add(1, "Budzki"); Console.WriteLine("Zawartosc slownika: "); Dict.Show(); Dict.Delete(1); Dict.Add(2, "Dominik"); Dict.Add(4, "II Uwr"); Dict.Add(9, "abcd"); Console.WriteLine("Zawartosc slownika: "); Dict.Show(); Dict.Add(3, "Programowanie_obiektowe"); Dict.Search(3); }
public void Add(K key, V value) { if (elem == null) { elem = new Slownik <K, V>(); elem.klucz = key; elem.wartosc = value; Console.WriteLine("Dodano obiekt o kluczu " + key + " z wartoscia " + value); return; } else { if (key.CompareTo(elem.klucz) == 0) { Console.WriteLine("Obiekt o takim kluczu znajduje sie juz w slowniku!"); return; } elem.Add(key, value); } }