本文整理汇总了C#中GenericList.GetAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.GetAtIndex方法的具体用法?C# GenericList.GetAtIndex怎么用?C# GenericList.GetAtIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.GetAtIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
Console.Title = "Problem 3. Generic ";
GenericList<int> numbers = new GenericList<int>();
numbers.Add(5);
numbers.Add(50);
numbers.Add(500);
numbers.Add(1000);
Console.WriteLine(numbers.Max());
Console.WriteLine(numbers.Min());
Console.WriteLine(numbers.GetAtIndex(1));
numbers.Insert(1, 25);
Console.WriteLine(numbers.IndexOf(50));
Console.WriteLine(numbers.Contains(5));
numbers.Remove(5);
Console.WriteLine(numbers);
numbers.Clear();
Console.WriteLine(numbers);
Console.WriteLine();
Console.WriteLine("Problem 4. Generic List Version");
System.Reflection.MemberInfo info = typeof(GenericList<>);
foreach (object attribute in info.GetCustomAttributes(false))
{
Console.WriteLine(attribute);
}
}
示例2: Main
static void Main()
{
GenericList<int> list = new GenericList<int>(10);
for (int i = 0; i < 6; i++)
{
list.Add(i);
}
Console.WriteLine(list.ToString());
Console.WriteLine("List state after initialization: ");
for (int i = 0; i < list.COUNT; i++)
{
Console.Write("{0} ", list.GetAtIndex(i));
}
list.RemoveAtIndex(2);
Console.WriteLine("\nList state after removing element at index {0}: ", list.INDEX);
for (int i = 0; i < list.COUNT; i++)
{
Console.Write("{0} ", list.GetAtIndex(i));
}
list.InsertAtIndex(7, 13);
Console.WriteLine("\nList state after inserting element at index {0}: ", list.INDEX);
for (int i = 0; i < list.COUNT; i++)
{
Console.Write("{0} ", list.GetAtIndex(i));
}
list.Add(14);
Console.WriteLine("\nList state after adding an element: ");
for (int i = 0; i < list.COUNT; i++)
{
Console.Write("{0} ", list.GetAtIndex(i));
}
list.Add(99);
Console.WriteLine("\nList state after adding another element: ");
for (int i = 0; i < list.COUNT; i++)
{
Console.Write("{0} ", list.GetAtIndex(i));
}
Console.WriteLine("\n" + list.ToString());
Console.WriteLine("MAX: {0}", GenericList<int>.Max(list));
Console.WriteLine("MIN: {0}", GenericList<int>.Min(list));
Console.WriteLine(list.GetAtIndex(list.GetByValue(4)));
}