The System.Collections.Generic namespace provides a collection of classes that define generic collections. One of the classes in this namespace is List, which represents a strongly typed list of objects.
The RemoveAt method is a member of the List class and is used to remove an element at a specified index position. It returns void and takes an integer representing the index of the element to be removed.
Example code:
List numbers = new List() { 1, 2, 3, 4, 5 };
numbers.RemoveAt(2);
foreach (int num in numbers) {
Console.WriteLine(num);
}
In this example, we create a List object and populate it with five integers. Then, we use the RemoveAt method to remove the third element (at index 2), which is the number 3. Finally, we use a foreach loop to iterate over the remaining elements in the list and print them to the console.
Package library: System.Runtime.dll, System.Collections.dll.
C# (CSharp) System.Collections.Generic System.Collections.Generic.List.RemoveAt - 36 examples found. These are the top rated real world C# (CSharp) examples of System.Collections.Generic.System.Collections.Generic.List.RemoveAt extracted from open source projects. You can rate examples to help us improve the quality of examples.