Exemple #1
0
 static void Main()
 {
     //Some tests. You can change values to check the correct work of the program.
     GenericList<int> sampleList = new GenericList<int>(5);
     sampleList.AddToGenericList(7);
     sampleList.AddToGenericList(5);
     sampleList.AddToGenericList(1);
     sampleList.AddToGenericList(70);
     sampleList.AddToGenericList(-7);
     string listElements = sampleList.ToString();
     Console.WriteLine("Sample list: {0}", listElements);
     int element = sampleList.AcessByIndex(1);
     Console.WriteLine("The value of the element on index 1 is {0}", element);
     sampleList.RemoveByIndex(1);
     Console.WriteLine("Sample list: {0}", sampleList);
     sampleList.InsertAtPosition(2, 222);
     Console.WriteLine("Sample list: {0}", sampleList);
     int index = sampleList.FindByValue(70);
     Console.WriteLine("1 is on index {0}", index);
     int min = sampleList.Min();
     int max = sampleList.Max();
     Console.WriteLine("Min value - {0} \nMax value - {1}", min, max);
     sampleList.ClearingList();
     Console.WriteLine("Sample list: {0}", sampleList);
 }
Exemple #2
0
    static void Main()
    {
        //Some tests. You can change values to check the correct work of the program.
        GenericList <int> sampleList = new GenericList <int>(5);

        sampleList.AddToGenericList(7);
        sampleList.AddToGenericList(5);
        sampleList.AddToGenericList(1);
        sampleList.AddToGenericList(70);
        sampleList.AddToGenericList(-7);
        string listElements = sampleList.ToString();

        Console.WriteLine("Sample list: {0}", listElements);
        int element = sampleList.AcessByIndex(1);

        Console.WriteLine("The value of the element on index 1 is {0}", element);
        sampleList.RemoveByIndex(1);
        Console.WriteLine("Sample list: {0}", sampleList);
        sampleList.InsertAtPosition(2, 222);
        Console.WriteLine("Sample list: {0}", sampleList);
        int index = sampleList.FindByValue(70);

        Console.WriteLine("1 is on index {0}", index);
        int min = sampleList.Min();
        int max = sampleList.Max();

        Console.WriteLine("Min value - {0} \nMax value - {1}", min, max);
        sampleList.ClearingList();
        Console.WriteLine("Sample list: {0}", sampleList);
    }
        static void Main()
        {
            GenericList<int> test = new GenericList<int>();
            test.AddElement(5);
            test.AddElement(6);
            test.AddElement(7);
            test.AddElement(8);
            test.AddElement(9);

            //testing method add
            Console.WriteLine(test);
            //testing insert method
            Console.WriteLine("Insert element 2 at position 4");
            test.InsertElement(4, 2);
            Console.WriteLine(test);
            //testing method remove
            Console.WriteLine("Removing element at pos 5");
            test.RemoveAtIndex(5);
            Console.WriteLine(test);
            int result = test.AccessElement(3);
            Console.WriteLine("Accessing element at index 3: ");
            Console.WriteLine(result);
            Console.WriteLine("Finding element by value '0': ");
            Console.WriteLine(test.FindElementByValue(0));

            Console.WriteLine("Clear!");
            test.ClearingList();
            Console.WriteLine(test);
            Console.WriteLine();
            Console.WriteLine("Doubling the size:");
            for (int i = 1; i < 15; i++)
            {
                test.AddElement(i);
            }
            //test.AddElement(1);
            Console.WriteLine(test);
            //testing min max
            Console.WriteLine("Biggest, smallest: ");
            Console.WriteLine(test.Max<int>());
            Console.WriteLine(test.Min<int>());
        }