Пример #1
0
        static void Main()
        {
            GenericList <int> list = new GenericList <int>();

            //Add some numbers in the list
            list.Add(1);
            list.Add(2);
            list.Add(6);
            list.Add(8);

            //Insert number at given position in the list
            list.Insert(3, 1);
            Console.WriteLine("List: {0}", list);
            Console.WriteLine("Count: {0}", list.Count);
            Console.WriteLine("Capacity: {0}", list.Capacity);

            //Find a number and get its index in the list
            Console.WriteLine("The number 3 is at position {0} in the list.", list.Find(3));

            //Get min and max numbers in the list
            Console.WriteLine("Max: " + list.Max());
            Console.WriteLine("Min: " + list.Min());

            //Clear the list
            list.Clear();
            Console.WriteLine("List: {0}", list);
        }
Пример #2
0
        static void Main(string[] args)
        {
            GenericList <int> test = new GenericList <int>(3);

            test.Add(1);
            test.Add(2);
            test.Add(3);
            test.Add(4);
            test.Add(5);
            test.Insert(1, 33);
            test.Insert(0, 22);
            test.Insert(6, 66);
            Console.WriteLine("List:");
            Console.WriteLine(test);
            Console.WriteLine("Min: {0}", test.Min());
            Console.WriteLine("Max: {0}", test.Max());
            test.RemoveAt(4);
            Console.WriteLine(test);
            Console.WriteLine("Position of '1' = {0}", test.IndexOf(1));
            Console.WriteLine("Position of '33' = {0}", test.IndexOf(33));
        }
Пример #3
0
        static void Main(string[] args)
        {
            GenericList <int> intList = new GenericList <int>(3);

            Console.WriteLine("I added things in the list!");
            intList.Add(1223);
            intList.Add(12);
            intList.Add(122);
            intList.Add(123344);
            Console.WriteLine(intList);

            Console.WriteLine("**********");

            intList.Insert(123, 2);
            Console.WriteLine("After Inserting 123 in position 2 count from 0 : \n{0}", intList);

            Console.WriteLine("**********");

            GenericList <string> stringList = new GenericList <string>(3);

            stringList.Add("kola");
            stringList.Add("voda");
            stringList.Add("kilo");
            stringList.Add("far");
            stringList.Add("doda");
            Console.WriteLine("After Adding(and resizing) \n{0}", stringList);

            Console.WriteLine("**********");

            stringList.Insert("az sum", 1);
            Console.WriteLine("After inserting az sum in position 1 count from 0: \n{0}", stringList);

            Console.WriteLine("The word kilo is in index: {0}", stringList.Find("kilo"));
            Console.WriteLine("This is the max element : {0}", stringList.Max());
            Console.WriteLine("This is the min element : {0}", stringList.Min());

            Console.WriteLine("**********");

            stringList.Remove(2);
            Console.WriteLine("After removing element in position 2\n{0}", stringList);

            Console.WriteLine("**********");


            stringList.Clear();
            Console.WriteLine("After clearing(there is nothing because we clear the list ): {0}  ", stringList);
        }