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.Add(String) Method is used to add a string to the end of the StringCollection.
public int Add (string value);
Here, value is the string to add to the end of the StringCollection. The value can be null.
Return Value: The zero-based index at which the new element is inserted.
Note: If Count is less than the capacity, this method is an O(1) operation. If the capacity needs to be increased to accommodate the new element, this method becomes an O(n) operation, where n is Count.
Below programs illustrate the use of StringCollection.Add(String) Method:
A B C D E
2 4 6 8 10
- C# | Copy the elements of a string array to the end of the StringCollection
- C# | Check if the specified string is in the StringCollection
- 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# | Index of first occurrence in StringCollection
- C# | Get or Set at specified index in StringCollection
- C# | Remove from the specified index of the StringCollection
- C# | Copy StringCollection at the specified index of array
- C# | Remove the first occurrence from the StringCollection
- C# | Remove all the strings from the StringCollection
- C# | Insert at the specified index in StringCollection
- C# | StringCollection Class
- C# | Get an enumerator that iterates through StringCollection
- C# | Check if two StringCollection objects are equal
- C# | Gets or sets the element at the specified index in StringCollection
- How to get Synchronize access to the StringCollection in C#
- How to create a StringCollection in C#
- C# | Add an object to the end of the Queue - Enqueue Operation
- C# | Add an object to the end of the ArrayList
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.