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.AddRange(String) method is used to copy the elements of a string array to the end of the StringCollection.
public void AddRange (string value);
Here, string value is an array of strings which will be added to the end of the StringCollection. The array itself can not be null but it can contain elements that are null.
Exception: This method will give ArgumentNullException if value is null.
- StringCollection accepts null as a valid value and allows duplicate elements.
- If the StringCollection can accommodate the new elements without increasing the capacity, this method is an O(n) operation, where n is the number of elements to be added. If the capacity needs to be increased to accommodate the new elements, this method becomes an O(n + m) operation, where n is the number of elements to be added and m is Count.
Below programs illustrate the use of StringCollection.AddRange(String) Method:
A B C D E
2 3 4 5 6
- C# | Copy StringCollection at the specified index of array
- C# | Add a string 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# | 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#
- Shallow Copy and Deep Copy in C#
- C# | Copy the elements of collection over a range of elements in 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.