static void Main(string[] args) { GenericList <int> list = new GenericList <int>(3); list.Add(1); list.Add(2); list.Add(3); list.Add(4); list.InsertElementAt(7, 3); Console.WriteLine(list.Max()); Console.WriteLine(list); }
public static void Main() { GenericList <int> testList = new GenericList <int>(5); testList.AddElement(10); testList.AddElement(20); testList.AddElement(30); testList.AddElement(40); testList.AddElement(50); testList.InsertElementAt(0, 60); testList.RemoveElementAt(0); testList.AddElement(60); testList.AddElement(70); testList.AddElement(0); Console.WriteLine(testList.Count); Console.WriteLine("Min: {0}", testList.Min()); Console.WriteLine("Max: {0}", testList.Max()); }
static void Main() { GenericList <int> intList = new GenericList <int>(); intList.AddElement(5); intList.AddElement(10); intList.AddElement(15); Console.WriteLine(intList); intList.InsertElementAt(1, 20); Console.WriteLine(intList); intList.RemoveElementAtIndex(2); Console.WriteLine(intList); intList.AddElement(50); intList.AddElement(60); Console.WriteLine(intList); Console.WriteLine("Elements Count: {0}", intList.Count); Console.WriteLine("Min: {0}", intList.Min()); Console.WriteLine("Max: {0}", intList.Max()); Console.WriteLine(new String('-', 30)); }
public static void Main() { GenericList <string> list = new GenericList <string>(); // Problem 5 Console.WriteLine("Empty GenericList"); Console.WriteLine(list); Console.WriteLine("List capacity: {0}\n", list.Capacity); Console.WriteLine("Adding elements to GenericList"); list.AddElement("first"); list.AddElement("second"); list.AddElement("third"); list.AddElement("fourth"); list.AddElement("fifth"); Console.WriteLine(list); Console.WriteLine("Removing an element at index [1]:"); list.RemoveElementAt(1); Console.WriteLine(list); Console.WriteLine("Inserting an element \"inserted\""); list.InsertElementAt(2, "inserted"); Console.WriteLine(list); Console.WriteLine("Element \"{0}\" is at index {1}\n", "fifth", list.FindElement("fifth")); Console.WriteLine("List capacity: {0}\n", list.Capacity); Console.WriteLine("Getting an element at index [2] -> \"{0}\"\n", list[2]); Console.WriteLine("Getting the minimal element: \"{0}\"\n", list.Min()); // Problem 7 Console.WriteLine("Getting the maximal element: \"{0}\"\n", list.Max()); // Problem 7 Console.WriteLine("Clearing the list..."); list.ClearGenericList(); Console.WriteLine(list); Console.WriteLine("List capacity: {0}\n", list.Capacity); }