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 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.
public bool Remove (T item);
item: Specified object which is to be remove from the List.
Return Type: This method returns True if item is successfully removed. Otherwise it returns False.
Note: This method returns False if item was not found in the List.
Below programs illustrate how to remove the specified element from the List:
Before Removing 1 2 3 4 After Removing 1 3 4
Before Removing 1 2 3 4 2 4 After Removing 1 3 4 2 4
- C# | Removing the specified key entry from HybridDictionary
- C# | Removing the specified node from the LinkedList<T>
- C# | Removing first occurrence of specified value from LinkedList<T>
- C# | Gets or Sets the element at the specified index in the List
- C# | How to remove the element from the specified index of the List
- C# | How to get the last occurrence of the element in the List that match the specified conditions
- C# | How to perform a specified action on each element of the List
- C# | How to check whether a List contains a specified element
- C# | Insert an element into the ArrayList at the specified index
- C# | Check if a HashSet contains the specified element
- C# | Remove the element with the specified key from the Hashtable
- C# | Remove the specified element from a HashSet
- C# | Remove the element at the specified index of the ArrayList
- C# | Remove the element with the specified key from a SortedList
- C# | Insert an element into Collection<T> at specified index
- C# | Remove element at specified index of Collection<T>
- C# | Performing Specified action on each element of Array
- C# | Get or set the element at the specified index in ArrayList
- C# | Adding the elements of the specified collection to the end of the List
- C# | How to insert the elements of a collection into the List at the specified index
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.