![]() |
VOOZH | about |
List<T>.RemoveRange(Int32, Int32) Method is used to remove a range of elements from the List<T>. Properties of List:
Syntax:
public void RemoveRange (int index, int count);
Parameters:
index: It is the zero-based starting index of the range of elements which is to be removed. count: It is the number of the elements which is to be removed.
Exceptions:
Below programs illustrate the use of List<T>.RemoveRange(Int32, Int32) Method: Example 1:
Output:
Elements in List: Geeks For Geeks GFG C# Tutorials GeeksforGeeks After Removing of elements: Geeks For Geeks C# Tutorials GeeksforGeeks
Time Complexity: O(n)
Auxiliary Space: O(n)
Example 2:
Output:
Elements in List: 1 2 3 4 5 6 7 After Removing of elements: 1 2 3 6 7
Time complexity: O(n) since using a loop
Auxiliary Space: O(n) where n is size of the list
Reference: