本文整理汇总了C#中GenericList.InsertElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.InsertElementAt方法的具体用法?C# GenericList.InsertElementAt怎么用?C# GenericList.InsertElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.InsertElementAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
GenericList<int> list = new GenericList<int>();
Console.WriteLine("Adding numbers:");
list.AddElement(3);
list.AddElement(5);
list.AddElement(12);
Console.WriteLine(list + Environment.NewLine); // Print
Console.WriteLine("Inserting [-3] at position [2]");
list.InsertElementAt(2, -3);
Console.WriteLine(list + Environment.NewLine); // Print
Console.WriteLine("Removing element at position [1]");
list.RemoveElementAtIndex(1);
Console.WriteLine(list + Environment.NewLine);
Console.WriteLine("Search for number [-3]");
Console.WriteLine(list.FindElementValue(-3) + Environment.NewLine);
Console.WriteLine("STATISTICS");
Console.WriteLine("Elements count: {0}", list.Count);
Console.WriteLine("Min element: {0}", list.Min());
Console.WriteLine("Max element: {0}", list.Max());
list.ClearList();
Console.WriteLine();
}
示例2: Main
static void Main(string[] args)
{
GenericList<int> list = new GenericList<int>(3);
list.Add(1);
list.Add(2);
list.Add(3);
list.Add(4);
list.InsertElementAt(7, 3);
Console.WriteLine(list.Max());
Console.WriteLine(list);
}
示例3: Main
static void Main()
{
GenericList<int> intList = new GenericList<int>();
intList.AddElement(5);
intList.AddElement(10);
intList.AddElement(15);
Console.WriteLine(intList);
intList.InsertElementAt(1, 20);
Console.WriteLine(intList);
intList.RemoveElementAtIndex(2);
Console.WriteLine(intList);
intList.AddElement(50);
intList.AddElement(60);
Console.WriteLine(intList);
Console.WriteLine("Elements Count: {0}", intList.Count);
Console.WriteLine("Min: {0}", intList.Min());
Console.WriteLine("Max: {0}", intList.Max());
Console.WriteLine(new String('-', 30));
}