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


C# GenericList.MaxT方法代码示例

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


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

示例1: Main

        static void Main()
        {
            // creating an initial array
            GenericList<int> testArray = new GenericList<int>(4);
            Console.WriteLine("The GenericList has {0} elements", testArray.Count);
            Console.WriteLine("The initial capacity is {0}\n", testArray.Capacity);

            // adding elemnts
            for (int i = 1; i < 5; i++)
            {
                testArray.Add(i * 5);
            }
            Console.WriteLine("Now in the GenericList you have {0} elements ", testArray.Count);
            Console.WriteLine("The object at position 1 is {0}\n", testArray[1]);

            // test To.String() method
            Console.WriteLine("ToString {0}\n", testArray);

            // test InsertAt method and FindElementIndex method
            var insertInt = 30;
            testArray.InsertAt(1, insertInt);

            Console.WriteLine("Capacity after AutoGrow is {0}", testArray.Capacity);
            Console.WriteLine("You can find {0} at index {1}"
                , insertInt, testArray.FindElementIndex(insertInt));
            Console.WriteLine("ToString {0}\n", testArray);

            // test RemoveAt method
            testArray.RemoveAt(1);

            Console.WriteLine("Now on position 1 is {0} and the count is {1}", testArray[1], testArray.Count);
            Console.WriteLine("ToString {0}\n", testArray);

            // test Min and Max
            Console.WriteLine("The smallest element is {0} and the biggest is {1}\n"
                , testArray.MinT(), testArray.MaxT());

            // test Clear method
            testArray.ClearList();
            Console.WriteLine("After clear there are {0} elements in the array\n", testArray.Count);
        }
开发者ID:tddold,项目名称:TelerikAcademyHomework,代码行数:41,代码来源:TestGeneric.cs

示例2: Main

        static void Main(string[] args)
        {
            GenericList<int> inputTest = new GenericList<int>(10);

            //Adding
            inputTest.Add(5);
            inputTest.Add(8);
            inputTest.Add(10);
            inputTest.Add(3);

            //Accessing
            int value= inputTest.AccessingByIndex(2);

            //Removing
            inputTest.Delete(2);

            //Inserting
            inputTest.Insert(1, 80);

            //Clearing
            //inputTest.Clear();

            //Finding element
            int index= inputTest.FindByValue(80);

            //ToString
            string output = inputTest.ToString();

            //Min value
            int minVal = inputTest.MinT();

            //Max value
            int maxVal = inputTest.MaxT();

            Console.WriteLine();
        }
开发者ID:zigzacvy,项目名称:Telerik_Akademy_Homework_CSharp,代码行数:36,代码来源:TestInput.cs


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