本文整理汇总了C#中GenericList.RemoveElementByIndex方法的典型用法代码示例。如果您正苦于以下问题:C# GenericList.RemoveElementByIndex方法的具体用法?C# GenericList.RemoveElementByIndex怎么用?C# GenericList.RemoveElementByIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenericList
的用法示例。
在下文中一共展示了GenericList.RemoveElementByIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
GenericList<int> test = new GenericList<int>();
Random randomNumber = new Random();
for (int i = 0; i < 10; i++)
{
test.AddElement(randomNumber.Next(1, 100));
}
Console.WriteLine("The GenericList is:\n {0}",test);
test.RemoveElementByIndex(0);
Console.WriteLine("After removing element by index, the GenericList is:\n {0}",test);
test.InsertElementByIndex(5, 89);
Console.WriteLine("After insert new element, the GenericList is:\n {0}", test);
test.FindElemByValue(89);
Console.WriteLine("The maximal element is: {0}",test.Maximum());
Console.WriteLine("The minimal element is: {0}", test.Minimum());
test.CleanList();
Console.WriteLine("After clearing the GenericList is: {0}",test);
}
示例2: Main
static void Main(string[] args)
{
Console.WriteLine("*********");
Console.WriteLine("POINT 3D:");
Console.WriteLine("*********");
Point3D testPoint1 = new Point3D(5, 6, 7);
Point3D testPoint2 = new Point3D(6, 7, 9);
Console.WriteLine("Point1: {0}", testPoint1);
Console.WriteLine("Point2: {0}", testPoint2);
Console.WriteLine("Distance: {0}", Distance3D.Distance(testPoint1, testPoint2));
Console.WriteLine();
Console.WriteLine("**************");
Console.WriteLine("GENERIC CLASS:");
Console.WriteLine("**************");
GenericList<int> testList = new GenericList<int>(2);
testList.AddElement(1);
testList.AddElement(2);
testList.AddElement(3);
testList.AddElement(4);
testList.AddElement(5);
testList.InsertElementAtGivenPosition(6, 1);
testList.RemoveElementByIndex(0);
Console.WriteLine(testList);
Console.WriteLine("Position of 4: {0}", testList.FindElementByValue(4));
Console.WriteLine("Max element: {0}", testList.Max());
Console.WriteLine("Min element: {0}", testList.Min());
Console.WriteLine("Count: {0}", testList.Count);
Console.WriteLine("Capacity: {0}", testList.Capacity);
testList.ClearList();
testList.AddElement(800);
Console.WriteLine(testList);
Console.WriteLine();
Console.WriteLine("*************");
Console.WriteLine("MATRIX CLASS:");
Console.WriteLine("*************");
Matrix<int> m1 = new Matrix<int>(3, 3);
Matrix<int> m2 = new Matrix<int>(3, 3);
// Fill with random numbers
Random randomGenerator = new Random();
for (int i = 0; i < m1.Rows; i++)
{
for (int j = 0; j < m1.Columns; j++)
{
m1[i, j] = randomGenerator.Next(20);
m2[i, j] = randomGenerator.Next(20);
}
}
Console.WriteLine("Matrix 1");
Console.WriteLine(m1);
Console.WriteLine("Matrix 2");
Console.WriteLine(m2);
Console.WriteLine("Matrix 1 + Matrix 2");
Console.WriteLine(m1 + m2);
Console.WriteLine("Matrix 1 - Matrix 2");
Console.WriteLine(m1 - m2);
Console.WriteLine("Matrix 1 * Matrix 2");
Console.WriteLine(m1 * m2);
Console.WriteLine("******************");
Console.WriteLine("VERSION ATTRIBUTE:");
Console.WriteLine("******************");
Type type = typeof(DefiningClasses);
object[] allCustomAttributes = type.GetCustomAttributes(false);
foreach (VersionAttribute attribute in allCustomAttributes)
{
Console.WriteLine("Current version is: {0}", attribute.FullVersion);
}
}