本文整理汇总了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);
}
示例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>());
}