本文整理汇总了C#中GenericList.PutAt方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.PutAt方法的具体用法?C# GenericList.PutAt怎么用?C# GenericList.PutAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.PutAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
GenericList<int> list = new GenericList<int>();
list.Add(2);
list.Add(3);
list.Add(4);
list.Add(10);
list.PutAt(3,6);
list.Add(9);
list.PutAt(3, 6);
list.Add(8);
list.Add(7);
list.Add(6);
list.Add(5);
Console.WriteLine("Full list: ");
Console.WriteLine(list + Environment.NewLine);
Console.WriteLine("does the list contain the digit 1?: "+list.Contains(1) + Environment.NewLine);
Console.WriteLine($"Element at position 0 is {list.GetAt(0)}"+ Environment.NewLine);
list.RemoveAt(0);
list.RemoveAt(3);
Console.WriteLine("Full list after removing digits at index 0 and 3: ");
Console.WriteLine(list + Environment.NewLine);
list.Clear();
Console.WriteLine("List after .Clear() command: ");
Console.WriteLine(list + Environment.NewLine);
list.RemoveAt(0);
list.Remove();
list.Remove();
list.Remove();
list.Remove();
list.Remove();
list.Remove();
list.Remove();
Console.WriteLine(list);
//this will throw exception because the list is cleared by now
//Console.WriteLine($"Element at position 0 is {list.GetAt(0)}");
}