using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { public class Zoznam { private Type[] prvky; private int pocetUlozenych; public Zoznam() { pocetUlozenych = 0; prvky = new Type[2]; } public void vloz(Type prvok) { if (pocetUlozenych >= prvky.Length) { Type[] nove = new Type[prvky.Length * 2]; for (int i = 0; i < prvky.Length; i++) { nove[i] = prvky[i]; } prvky = nove; } prvky[pocetUlozenych] = prvok; pocetUlozenych++; } public void vypisVsetko() { for (int i = 0; i < pocetUlozenych; i++) { Console.Write(prvky[i]); Console.Write(", "); } Console.WriteLine(); Console.WriteLine(prvky.Length); } } 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("stringovy swap"); //} static void Main(string[] args) { Zoznam mojZoznam = new Zoznam(); Zoznam slova = new Zoznam(); List cisla = new List(); cisla.Clear(); cisla.Contains(4); cisla.Add(543); cisla.Sort(); cisla[0] = 3; SortedList slovnik = new SortedList(); slovnik.Add(5, "ahoj"); slovnik.Add(3, "jan"); Console.WriteLine(slovnik[5]); Console.WriteLine(slovnik.First().Value); HashSet mnozina = new HashSet(); HashSet mnozina2 = new HashSet(); mnozina.Add("lalal"); mnozina.Add("fasfDFasf"); mnozina.Add("lalal"); mnozina.IntersectWith(mnozina2); Dictionary dvojice = new Dictionary(); dvojice.Add("k1", "ahoj"); dvojice.Add("k2", "lalala"); Console.WriteLine(dvojice["k1"]); //Console.WriteLine(dvojice["fasdgdsf"]); spadne dvojice.Remove("k2"); dvojice.Clear(); SortedDictionary>> xxx = new SortedDictionary>>(); // na pracu so stringmi po znakoch StringBuilder sb = new StringBuilder(); for (int i = 0; i < 100; i++) { mojZoznam.vloz(i * 5); } mojZoznam.vypisVsetko(); int a = 10; int b = 46; string sa = "ahoj"; string sb2 = "josef"; double d1 = 0.55; double d2 = 0.212131; swap(ref a, ref b); swap(ref d1, ref d2); swap(ref sa, ref sb2); //Console.WriteLine(a); //Console.WriteLine(b); } } }