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


C# GenericList.ClearingList方法代码示例

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


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

示例1: Main

 static void Main()
 {
     //Some tests. You can change values to check the correct work of the program.
     GenericList<int> sampleList = new GenericList<int>(5);
     sampleList.AddToGenericList(7);
     sampleList.AddToGenericList(5);
     sampleList.AddToGenericList(1);
     sampleList.AddToGenericList(70);
     sampleList.AddToGenericList(-7);
     string listElements = sampleList.ToString();
     Console.WriteLine("Sample list: {0}", listElements);
     int element = sampleList.AcessByIndex(1);
     Console.WriteLine("The value of the element on index 1 is {0}", element);
     sampleList.RemoveByIndex(1);
     Console.WriteLine("Sample list: {0}", sampleList);
     sampleList.InsertAtPosition(2, 222);
     Console.WriteLine("Sample list: {0}", sampleList);
     int index = sampleList.FindByValue(70);
     Console.WriteLine("1 is on index {0}", index);
     int min = sampleList.Min();
     int max = sampleList.Max();
     Console.WriteLine("Min value - {0} \nMax value - {1}", min, max);
     sampleList.ClearingList();
     Console.WriteLine("Sample list: {0}", sampleList);
 }
开发者ID:PavDragneva,项目名称:TelerikAcademy,代码行数:25,代码来源:Start.cs

示例2: Main

        static void Main()
        {
            GenericList<int> test = new GenericList<int>();
            test.AddElement(5);
            test.AddElement(6);
            test.AddElement(7);
            test.AddElement(8);
            test.AddElement(9);

            //testing method add
            Console.WriteLine(test);
            //testing insert method
            Console.WriteLine("Insert element 2 at position 4");
            test.InsertElement(4, 2);
            Console.WriteLine(test);
            //testing method remove
            Console.WriteLine("Removing element at pos 5");
            test.RemoveAtIndex(5);
            Console.WriteLine(test);
            int result = test.AccessElement(3);
            Console.WriteLine("Accessing element at index 3: ");
            Console.WriteLine(result);
            Console.WriteLine("Finding element by value '0': ");
            Console.WriteLine(test.FindElementByValue(0));

            Console.WriteLine("Clear!");
            test.ClearingList();
            Console.WriteLine(test);
            Console.WriteLine();
            Console.WriteLine("Doubling the size:");
            for (int i = 1; i < 15; i++)
            {
                test.AddElement(i);
            }
            //test.AddElement(1);
            Console.WriteLine(test);
            //testing min max
            Console.WriteLine("Biggest, smallest: ");
            Console.WriteLine(test.Max<int>());
            Console.WriteLine(test.Min<int>());
        }
开发者ID:joro1881,项目名称:CSharpProgramming,代码行数:41,代码来源:ValidationUnit.cs


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