Esempio n. 1
0
        static void Main(string[] args)
        {
            GenericList <int> numbers = new GenericList <int>();

            numbers.Add(3);
            numbers.Add(5);
            numbers.Add(15);
            numbers.Add(45);
            numbers.Add(67);

            Console.WriteLine("List: " + numbers);
            numbers.InsertElementAt(100, 3);
            Console.WriteLine("List after InsertElementAt: " + numbers);
            numbers.RemoveElementAtIndex(4);
            Console.WriteLine("List after RemoveElementAtIndex: " + numbers);
            Console.WriteLine("Element at index - 2: " + numbers.ElementAtIndex(2));
            Console.WriteLine("Index of element - 100: " + numbers.IndexOf(100));
            Console.WriteLine("Contains - 3: " + numbers.Contains(3));
            Console.WriteLine("Min: " + numbers.Min());
            Console.WriteLine("Max: " + numbers.Max());
            Console.WriteLine();

            GenericList <string> names = new GenericList <string>();

            names.Add("Pesho");
            names.Add("Gosho");
            names.Add("Ivan");

            Console.WriteLine("List: " + names);
            names.InsertElementAt("Mariika", 3);
            Console.WriteLine("List after InsertElementAt: " + names);
            names.RemoveElementAtIndex(2);
            Console.WriteLine("List after RemoveElementAtIndex: " + names);
            Console.WriteLine("Element at index - 2: " + names.ElementAtIndex(2));
            Console.WriteLine("Index of element - Pesho: " + names.IndexOf("Pesho"));
            Console.WriteLine("Contains - Ivan: " + names.Contains("Ivan"));
            Console.WriteLine();

            Console.WriteLine(names.Version());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            var list = new GenericList <int> {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20
            };

            list.Version();
            Console.WriteLine(list.Count);
            list.Add(1);
            Console.WriteLine(list.Count);
            Console.WriteLine(list.Min());
            Console.WriteLine(list.Max());
            Console.WriteLine(list.Contains(6));
            Console.WriteLine(list.FindIndex(17));
            list.Insert(21341, 12);
            Console.WriteLine(list);
            list.Remove(0);
            Console.WriteLine(list);
            list[2] = 23;
            Console.WriteLine(list);
            list.Clear();
            Console.WriteLine(list);
        }