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