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 StringCollection.
public void RemoveAt (int index);
Here, index is the zero-based index of the string to remove.
Exception: This method will give ArgumentOutOfRangeException if the index is less than zero or index is equal to or greater than Count.
Note: This method is an O(n) operation, where n is Count.
Below programs illustrate the use of StringCollection.RemoveAt(Int32) Method:
Elements in StringCollection myCol are : A B C D E Elements in StringCollection myCol are : A B C E
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
- C# | Get or Set at specified index in StringCollection
- C# | Copy StringCollection at the specified index of array
- C# | Insert at the specified index in StringCollection
- C# | Gets or sets the element at the specified index in StringCollection
- C# | Check if the specified string is in the StringCollection
- C# | Index of first occurrence in StringCollection
- C# | Remove the first occurrence from the StringCollection
- C# | Remove all the strings from the StringCollection
- Creating an Index From the Specified Index at the Start of a Collection in C#
- Creating an Index From the End of a Collection at a Specified Index Position in C#
- C# | Remove the element at the specified index of the ArrayList
- C# | How to remove the element from the specified index of the List
- C# | Remove from the specified index of a SortedList
- C# | Remove the entry at specified index from OrderedDictionary
- C# | Remove element at specified index of Collection<T>
- C# | Check if the StringCollection is read-only
- C# | Check if StringCollection is synchronized (thread safe)
- C# | Get the number of strings in StringCollection
- C# | Add a string to the end of the StringCollection
- C# | Copy the elements of a string array to the end of the StringCollection
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.