本文整理汇总了C#中GenericList.MinT方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.MinT方法的具体用法?C# GenericList.MinT怎么用?C# GenericList.MinT使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.MinT方法的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);
}
示例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();
}