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.IndexOf(String) method is used to search the specified string which returns the zero-based index of the first occurrence within the StringCollection.
public int IndexOf (string value);
Here, value is the string to locate. The value can be null.
Return Value: The method returns zero-based index of the first occurrence of value in the StringCollection, if found otherwise it returns -1.
Note: This method performs a linear search. Therefore, this method is an O(n) operation, where n is Count.
Below programs illustrate the use of StringCollection.IndexOf(String) method:
- C# | Remove the first occurrence from the StringCollection
- C# | Get or Set at specified index in StringCollection
- C# | Remove from the specified index of the StringCollection
- C# | Insert at the specified index in StringCollection
- C# | Copy StringCollection at the specified index of array
- C# | Gets or sets the element at the specified index in StringCollection
- C# | Add a string to the end of the StringCollection
- How to create a StringCollection in C#
- C# | StringCollection Class
- C# | Check if the StringCollection is read-only
- C# | Get the number of strings in StringCollection
- C# | Get an enumerator that iterates through StringCollection
- C# | Remove all the strings from the StringCollection
- How to get Synchronize access to the StringCollection in C#
- C# | Check if the specified string is in the StringCollection
- C# | Check if two StringCollection objects are equal
- C# | Copy the elements of a string array to the end of the StringCollection
- C# | Check if StringCollection is synchronized (thread safe)
- Creating an Index From the End of a Collection at a Specified Index Position in C#
- Creating an Index From the Specified Index at the Start of a Collection in C#
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.