当前位置: 首页>>代码示例>>C#>>正文


C# GenericList.GetAtIndex方法代码示例

本文整理汇总了C#中GenericList.GetAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.GetAtIndex方法的具体用法?C# GenericList.GetAtIndex怎么用?C# GenericList.GetAtIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GenericList的用法示例。


在下文中一共展示了GenericList.GetAtIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        public static void Main()
        {
            Console.Title = "Problem 3.	Generic ";

            GenericList<int> numbers = new GenericList<int>();
            numbers.Add(5);
            numbers.Add(50);
            numbers.Add(500);
            numbers.Add(1000);

            Console.WriteLine(numbers.Max());
            Console.WriteLine(numbers.Min());

            Console.WriteLine(numbers.GetAtIndex(1));
            numbers.Insert(1, 25);
            Console.WriteLine(numbers.IndexOf(50));
            Console.WriteLine(numbers.Contains(5));
            numbers.Remove(5);
            Console.WriteLine(numbers);
            numbers.Clear();
            Console.WriteLine(numbers);

            Console.WriteLine();
            Console.WriteLine("Problem 4.	Generic List Version");
            System.Reflection.MemberInfo info = typeof(GenericList<>);
            foreach (object attribute in info.GetCustomAttributes(false))
            {
                Console.WriteLine(attribute);
            }
        }
开发者ID:Nezhdetov,项目名称:Software-University,代码行数:30,代码来源:GenericListMain.cs

示例2: Main

        static void Main()
        {
            GenericList<int> list = new GenericList<int>(10);
            for (int i = 0; i < 6; i++)
            {
                list.Add(i);
            }
            Console.WriteLine(list.ToString());
            Console.WriteLine("List state after initialization: ");
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.RemoveAtIndex(2);
            Console.WriteLine("\nList state after removing element at index {0}: ", list.INDEX);
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.InsertAtIndex(7, 13);
            Console.WriteLine("\nList state after inserting element at index {0}: ", list.INDEX);
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.Add(14);
            Console.WriteLine("\nList state after adding an element: ");
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            list.Add(99);
            Console.WriteLine("\nList state after adding another element: ");
            for (int i = 0; i < list.COUNT; i++)
            {
                Console.Write("{0} ", list.GetAtIndex(i));
            }

            Console.WriteLine("\n" + list.ToString());

            Console.WriteLine("MAX: {0}", GenericList<int>.Max(list));
            Console.WriteLine("MIN: {0}", GenericList<int>.Min(list));

            Console.WriteLine(list.GetAtIndex(list.GetByValue(4)));
        }
开发者ID:iliantova,项目名称:Telerik-Homework,代码行数:49,代码来源:MinAndMax.cs


注:本文中的GenericList.GetAtIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。