using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Zoznam { private Type[] zoznam; private int ulozenePrvky; public Zoznam() { zoznam = new Type[2]; ulozenePrvky = 0; } public void vloz(Type prvok) { if (ulozenePrvky >= zoznam.Length) { Type[] nove = new Type[zoznam.Length * 2]; zoznam.CopyTo(nove, 0); zoznam = nove; } zoznam[ulozenePrvky] = prvok; ulozenePrvky++; } public void vypis() { for (int i = 0; i < ulozenePrvky; i++) { Console.Write(zoznam[i]); Console.Write(", "); } } } class Program { public static void swap(ref Typename a, ref Typename b) { Typename tmp = a; a = b; b = tmp; Console.WriteLine("obecny swap"); } public static void swap(ref string a, ref string b) { string tmp = a; a = b; b = tmp; Console.WriteLine("string swap"); } static void Main(string[] args) { List cisla = new List(); cisla.Add(6); cisla.Add(4); cisla.Remove(6); cisla.Sort(); cisla.Insert(0, 121); cisla.Contains(11); // je tam 11? Console.WriteLine(cisla[0]); cisla[0] = 188; SortedList sortStrings = new SortedList(); sortStrings.Add(5, "ahoj"); sortStrings.Add(1, "cau"); Console.WriteLine(sortStrings[5]); Console.WriteLine(sortStrings.First().Value); SortedList xyz = new SortedList(); xyz.Add(0.1, "ahoj"); xyz.Add(0.2, "hello"); Console.WriteLine(xyz[0.1]); Dictionary lala = new Dictionary(); lala.Add(4, "ahoj"); //lala.Add(4, "lalala"); HashSet ahoj = new HashSet(); var ahoj2 = new HashSet(); ahoj.Add(4); ahoj.Add(53); ahoj.Add(4); foreach (int item in ahoj) { Console.WriteLine(item); } ahoj.IntersectWith(cisla); ahoj.UnionWith(ahoj2); Dictionary uloha = new Dictionary(); string slovo = "computer"; if (uloha.ContainsKey(slovo)) { uloha[slovo]++; } else { uloha.Add(slovo, 1); } SortedList zotUloha = new SortedList(); foreach (var polozka in uloha) { zotUloha.Add(polozka.Value, polozka.Key); } for (int i = 0; i < 20; i++) { Console.WriteLine(zotUloha[i]); } Zoznam mojeCisla = new Zoznam(); Zoznam mojeStringy = new Zoznam(); Zoznam>> blalala = new Zoznam>>(); for (int i = 0; i < 100; i++) { mojeCisla.vloz(i * 7); } mojeCisla.vypis(); int a = 5, b = 10; string sa = "lalal", sb = "haha"; swap(ref a, ref b); Console.WriteLine(a); Console.WriteLine(b); swap(ref sa, ref sb); Console.WriteLine(sa); Console.WriteLine(sb); double da = 0.32, db = 0.34242; swap(ref da, ref db); } } }