C# | How to remove the element from the specified index of the List Last Updated : 01 Feb, 2019 Comments Improve Suggest changes Like Article Like Report List<T>.RemoveAt (Int32) Method is used to remove the element at the specified index of the List<T>. Properties of List: It is different from the arrays. A list can be resized dynamically but arrays cannot. List class can accept null as a valid value for reference types and it also allows duplicate elements. If the Count becomes equals to Capacity then the capacity of the List increases automatically by reallocating the internal array. The existing elements will be copied to the new array before the addition of the new element. Syntax: public void RemoveAt (int index); Parameters: index: It is the zero-based starting index of the element which is to be removed. count: It is the number of the elements which is to be removed. Exceptions: This method will give ArgumentOutOfRangeException if the index is less than 0 or equal to or greater than Count. Below programs illustrate the use of List<T>.RemoveAt (Int32) Method: Example 1: CSharp // C# Program to remove the element at // the specified index of the List<T> using System; using System.Collections; using System.Collections.Generic; class Geeks { // Main Method public static void Main(String[] args) { // Creating an List<T> of Integers List<int> firstlist = new List<int>(); // Adding elements to List firstlist.Add(17); firstlist.Add(19); firstlist.Add(21); firstlist.Add(9); firstlist.Add(75); firstlist.Add(19); firstlist.Add(73); Console.WriteLine("Elements Present in List:\n"); int p = 0; // Displaying the elements of List foreach(int k in firstlist) { Console.Write("At Position {0}: ", p); Console.WriteLine(k); p++; } Console.WriteLine(" "); // removing the element at index 3 Console.WriteLine("Removing the element at index 3\n"); // 9 will remove from the List // and 75 will come at index 3 firstlist.RemoveAt(3); int p1 = 0; // Displaying the elements of List foreach(int n in firstlist) { Console.Write("At Position {0}: ", p1); Console.WriteLine(n); p1++; } } } Output: Elements Present in List: At Position 0: 17 At Position 1: 19 At Position 2: 21 At Position 3: 9 At Position 4: 75 At Position 5: 19 At Position 6: 73 Removing the element at index 3 At Position 0: 17 At Position 1: 19 At Position 2: 21 At Position 3: 75 At Position 4: 19 At Position 5: 73 Example 2: CSharp // C# Program to remove the element at // the specified index of the List<T> using System; using System.Collections; using System.Collections.Generic; class Geeks { // Main Method public static void Main(String[] args) { // Creating an List<T> of Integers List<int> firstlist = new List<int>(); // Adding elements to List firstlist.Add(17); firstlist.Add(19); firstlist.Add(21); firstlist.Add(9); firstlist.Add(75); firstlist.Add(19); firstlist.Add(73); Console.WriteLine("Elements Present in List:\n"); int p = 0; // Displaying the elements of List foreach(int k in firstlist) { Console.Write("At Position {0}: ", p); Console.WriteLine(k); p++; } Console.WriteLine(" "); // removing the element at index 3 Console.WriteLine("Removing the element at index 3\n"); // taking negative index // it will give error as index // cannot be less than 0 firstlist.RemoveAt(-1); int p1 = 0; // Displaying the elements of List foreach(int n in firstlist) { Console.Write("At Position {0}: ", p1); Console.WriteLine(n); p1++; } } } Runtime Error: Unhandled Exception: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index Output: Elements Present in List: At Position 0: 17 At Position 1: 19 At Position 2: 21 At Position 3: 9 At Position 4: 75 At Position 5: 19 At Position 6: 73 Removing the element at index 3 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1.removeat?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | How to remove the element from the specified index of the List K Kirti_Mangal Follow Improve Article Tags : C# CSharp-method CSharp-Generic-List CSharp-Collections-Namespace CSharp-Generic-Namespace +1 More Similar Reads C# | Remove the element with the specified key from the Hashtable The Hashtable class represents a collection of key-and-value pairs that are organized based on the hash code of the key. The key is used to access the items in the collection. Hashtable.Remove(Object) Method is used to remove the element with the specified key from the Hashtable. Syntax: public virt 2 min read C# | Removing the specified element from the List List.Remove(T) Method is used to remove the first occurrence of a specific object from the List. Properties of List: It is different from the arrays. A list can be resized dynamically but arrays cannot. List class can accept null as a valid value for reference types and it also allows duplicate elem 2 min read C# | Remove the element at the specified index of the ArrayList ArrayList represents an ordered collection of an object that can be indexed individually. It is basically an alternative to an array. It also allows dynamic memory allocation, adding, searching and sorting items in the list. ArrayList.RemoveAt(Int32) method is used to remove the element at the speci 3 min read C# | Removing the specified node from the LinkedList<T> Remove(LinkedListNode<T>) method is used to remove the specified node from the LinkedList<T>. Syntax: public void Remove (System.Collections.Generic.LinkedListNode<T> node); Here, node is the LinkedListNode<T> to remove from the LinkedList<T>. Exceptions: ArgumentNullEx 2 min read C# | Remove from the specified index of the StringCollection StringCollection class is a new addition to the .NET Framework class library that represents a collection of strings. StringCollection class is defined in the System.Collections.Specialized namespace. StringCollection.RemoveAt(Int32) method is used to remove the string at the specified index of the 3 min read Like