Пример #1
0
        static void Main(string[] args)
        {
            GenericList <string> genericList = new GenericList <string>();

            genericList.Add("a");
            genericList.Add("b");
            genericList.Add("c");
            Console.WriteLine(genericList);
            Console.WriteLine("Max = {0}, Min = {1}", genericList.Max(), genericList.Min());
            Console.WriteLine("Remove b");
            genericList.Remove("b");
            Console.WriteLine(genericList);
            Console.WriteLine("genericList[0] = " + genericList.Access(0));
            Console.WriteLine("index of c = " + genericList.FindIndex("c"));
            genericList.Clear();
            genericList.Add("rom");
            genericList.Add("mon");
            genericList.Add("dom");
            Console.WriteLine(genericList);
            Console.WriteLine("Insert zom (index = 1)");
            genericList.Insert("zom", 1);
            Console.WriteLine(genericList);
            Console.WriteLine(genericList.Contains("mon"));
            Console.WriteLine(genericList.Contains("aaa"));

            Type type = typeof(GenericList <>);

            object[] allAttributes = type.GetCustomAttributes(typeof(VersionAttribute), false);
            foreach (VersionAttribute attr in allAttributes)
            {
                Console.WriteLine("This class's version is {0}.", attr.Version);
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            var list = new GenericList <int>();

            list.Add(1);
            list.Add(2);
            list.Add(3);
            list.Add(4);
            list.Add(5);

            list[4] = 19;
            Console.WriteLine(list);

            list.Add(-5);
            Console.WriteLine(list);

            Console.WriteLine("list[4] = " + list[4]);

            list.RemoveByIndex(list.Count - 1);
            Console.WriteLine(list);
            Console.WriteLine("{0}", new string('-', 60));

            list.Insert(list.Count, 5);
            Console.WriteLine(list);
            Console.WriteLine("{0}", new string('-', 60));

            Console.WriteLine(list.GetIndexByValue(5));
            Console.WriteLine(list.IsContain(8));
            Console.WriteLine("{0}", new string('-', 60));

            Console.WriteLine("Highest = " + list.Max());
            Console.WriteLine("Lowest = " + list.Min());
            Console.WriteLine("{0}", new string('-', 60));

            list.RemoveAll();
            Console.WriteLine("After the List was Deleted = " + list);
            Console.WriteLine("{0}", new string('-', 60));

            Type type = typeof(GenericList <>);

            object[] allAttributes = type.GetCustomAttributes(typeof(VersionAttribute), true);
        }