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.Remove(String) method is used to remove the first occurrence of a specific string from the StringCollection.
public void Remove (string value);
Here, value is the string which is to be removed from the StringCollection. The value can be null.
- Duplicate strings are allowed in StringCollection.
- Only the first occurrence is removed. To remove all occurrences of the specified string, use RemoveAt(IndexOf(value)) repeatedly while IndexOf does not return -1.
- If the StringCollection does not contain the specified object, the StringCollection remains unchanged. No exception is thrown.
- This method performs a linear search; therefore, this method is an O(n) operation, where n is Count.
Elements in StringCollection are : A A A B C C D D E Elements in StringCollection are : A A B C C D D E Elements in StringCollection are : A A B C D D E Elements in StringCollection are : A B C D D E Elements in StringCollection are : A B C D D E
- C# | Index of first occurrence in StringCollection
- C# | Remove all the strings from the StringCollection
- C# | Remove from the specified index of the StringCollection
- C# | Remove the first occurrence of a specific object from the ArrayList
- C# | Add a string to the end of the StringCollection
- How to create a StringCollection in C#
- C# | Get or Set at specified index in StringCollection
- C# | StringCollection Class
- C# | Check if the StringCollection is read-only
- C# | Insert at the specified index in StringCollection
- C# | Get an enumerator that iterates through StringCollection
- C# | Check if the specified string is in the StringCollection
- C# | Get the number of strings in StringCollection
- How to get Synchronize access to the StringCollection in C#
- C# | Check if two StringCollection objects are equal
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.