Remove Item at a specified position in a C# List

List<T> provides RemoveAt() method to remote items at a specified position. Code examples in this article removes an item at a specified position using C# and .NET.

C# List is a collection of objects. In a List ojbect, the Remove method removes the first occurrence of a specific object from a List. The Remove method takes an item as its parameter. The following code snippet removes an item from a List.
  1. // Create a list of strings  
  2. List<string> AuthorList = new List<string>();  
  3. AuthorList.Add("Mahesh Chand");  
  4. AuthorList.Add("Praveen Kumar");  
  5. AuthorList.Add("Raj Kumar");  
  6. AuthorList.Add("Nipun Tomar");  
  7. AuthorList.Add("Dinesh Beniwal");  
  8.   
  9. AuthorList.Remove("Mahesh Chand");  
The RemoveAt method removes an item at the specified zero based index. The following code snippet removes an item at 2nd position in the List.
  1. AuthorList.RemoveAt(2);  
The RemoveRange method removes a number of items based on the specified starting index and number of items. The RemoveRange method takes first parameter as the starting position and second parameter as the number of the items to be removed from the List. The following code snippet removes 2 items starting at the 3rd position. 
  1. AuthorList.RemoveRange(3, 2);  
The Clear method removes all items from the List. The following code snippet removes all items by calling the Clear method.