static void Main(string[] args) { Dictionary <int, string> sehirler = new Dictionary <int, string>(); sehirler.Add(1, "Adana"); sehirler.Add(2, "Adıyaman"); sehirler.Add(3, "Afyon"); sehirler.Add(4, "Ağrı"); sehirler.Add(5, "Amasya"); sehirler.Add(6, "Ankara"); foreach (var sehir in sehirler) { //Console.WriteLine(sehir.Key + " plakalı şehir: " + sehir.Value); } MyDictionary <int, string> x = new MyDictionary <int, string>(); x.Add(7, "Antalya"); x.Add(8, "Artvin"); }
static void Main(string[] args) { //1 MyList <int> myList1 = new MyList <int>(); Console.WriteLine(myList1.Count); myList1.Add(7); myList1.Add(9); myList1.Add(0); myList1.Add(3); foreach (int item in myList1) { Console.Write("{0} ", item); } Console.WriteLine(); MyList <int> myList2 = new MyList <int>(new int[] { 1, 3, 4, 9 }); foreach (int item in myList2) { Console.Write("{0} ", item); } Console.WriteLine(); myList2.AddRange(new int[] { 8, 8, 8, 8 }); foreach (int item in myList2) { Console.Write("{0} ", item); } Console.WriteLine(); Console.WriteLine(); //2 MyDictionary <int, string> countries = new MyDictionary <int, string>(); countries.Add(1, "Russia"); countries.Add(3, "Great Britain"); countries.Add(2, "USA"); countries.Add(4, "France"); countries.Add(5, "China"); foreach (KeyValuePair <int, string> item in countries) { Console.Write("{0} - {1}", item.Key, item.Value); Console.WriteLine(); } Console.WriteLine(); //3 MyList <int> myList3 = new MyList <int>(new int[] { 9, 8, 5, 5, 0 }); Array.ForEach(myList3.GetArray(), Console.Write); Console.WriteLine(); Console.WriteLine(); //4 int[] array = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 }; foreach (int i in GetEvenNumbers(array)) { Console.Write("{0} ", i); } Console.ReadLine(); }
static void Main(string[] args) { /* * MyStack<string> myStack1 = new MyStack<string>(40); * myStack1.pop(); * myStack1.push("sddfsf"); * myStack1.push("qweqwe"); * myStack1.push("fhgfh"); * myStack1.push("123123"); * * myStack1.pop(); * * * * MyStack<double> myStack2 = new MyStack<double>(40); * myStack2.push(4.5); * myStack2.push(-45.5); * myStack2.push(2345.5); */ /* * MyQueue<string> myQueue1 = new MyQueue<string>(45); * myQueue1.Enqueue("qwerty"); * myQueue1.Enqueue("zxcsdf"); * * myQueue1.Dequeue(); * * Console.WriteLine(myQueue1.Peek()); */ /* * MyQueue<int> myQueue = new MyQueue<int>(2); * * myQueue.Enqueue(4); * myQueue.Enqueue(5); * myQueue.Enqueue(6); * * Console.WriteLine(myQueue.Peek()); * Console.WriteLine(myQueue.Dequeue()); * Console.WriteLine(myQueue.Dequeue()); * Console.WriteLine(myQueue.Dequeue()); */ MyDictionary <int, string> myDictionary = new MyDictionary <int, string>(); myDictionary.Add(1, "sdf"); myDictionary.Add(2, "234234"); myDictionary.Add(45, "234234"); myDictionary[1] = "1223"; myDictionary[78] = "qwerty"; Console.WriteLine(myDictionary[1]); Console.WriteLine(myDictionary[5]); Console.WriteLine(myDictionary[78]); Console.ReadKey(); }