Exemple #1
0
        static void Main(string[] args)
        {
            IntegerList.IntegerList il = new IntegerList.IntegerList();
            il.ListExample(il);

            GenericList.GenericList <String> stringList = new GenericList.GenericList <string>();
            stringList.Add("1");
            stringList.Add("2");
            stringList.Add("3");
            stringList.Add("4");
            stringList.Add("5");
            stringList.Add("6");
            stringList.Add("7");
            Console.WriteLine("FOREACH");
            // foreach
            foreach (string value in stringList)
            {
                Console.WriteLine(value);
            }
            Console.WriteLine("WITHOUT SYNTAX SUGAR");
            // foreach without the syntax sugar
            IEnumerator <string> enumerator = stringList.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string value = (string)enumerator.Current;
                Console.WriteLine(value);
            }
            Console.ReadLine();
        }
        static void Main()
        {
            var myList = new GenericList.GenericList<int>(2);
            myList.Add(2);
            myList.Add(3);
            myList.Add(4);
            myList.Add(2);
            myList.Add(3);
            myList.Add(4);

            myList.InsertElementAtIndex(7, 5);
            myList.RemoveElementAtIndex(3);

            Console.WriteLine("My list: {0}", myList);
            Console.WriteLine();

            Console.WriteLine("The index of the found element is: {0}", myList.FindElement(7));
            Console.WriteLine();

            Console.WriteLine("The smallest element is: {0}", myList.Min());
            Console.WriteLine();
            Console.WriteLine("The biggest element is: {0}", myList.Max());

            myList.Clear();
            Console.WriteLine();
            Console.WriteLine(myList);
        }
Exemple #3
0
        static void Main()
        {
            var myList = new GenericList.GenericList <int>(2);

            myList.Add(2);
            myList.Add(3);
            myList.Add(4);
            myList.Add(2);
            myList.Add(3);
            myList.Add(4);

            myList.InsertElementAtIndex(7, 5);
            myList.RemoveElementAtIndex(3);

            Console.WriteLine("My list: {0}", myList);
            Console.WriteLine();

            Console.WriteLine("The index of the found element is: {0}", myList.FindElement(7));
            Console.WriteLine();

            Console.WriteLine("The smallest element is: {0}", myList.Min());
            Console.WriteLine();
            Console.WriteLine("The biggest element is: {0}", myList.Max());

            myList.Clear();
            Console.WriteLine();
            Console.WriteLine(myList);
        }