C# | Add a string to the end of the StringCollection Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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. Syntax: 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: Example 1: CSHARP // C# code to add a string to the // end of the StringCollection using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // creating a StringCollection named myCol StringCollection myCol = new StringCollection(); // Adding elements in StringCollection myCol.Add("A"); myCol.Add("B"); myCol.Add("C"); myCol.Add("D"); myCol.Add("E"); // Displaying objects in myCol foreach(Object obj in myCol) { Console.WriteLine(obj); } } } Output: A B C D E Example 2: CSHARP // C# code to add a string to the // end of the StringCollection using System; using System.Collections; using System.Collections.Specialized; class GFG { // Driver code public static void Main() { // creating a StringCollection named myCol StringCollection myCol = new StringCollection(); // Adding elements in StringCollection myCol.Add("2"); myCol.Add("4"); myCol.Add("6"); myCol.Add("8"); myCol.Add("10"); // Displaying objects in myCol foreach(Object obj in myCol) { Console.WriteLine(obj); } } } Output: 2 4 6 8 10 Reference: https://learn.microsoft.com/en-us/dotnet/api/system.collections.specialized.stringcollection.add?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article How to create a StringCollection in C# S Sahil_Bansall Follow Improve Article Tags : C# CSharp-method CSharp-Collections-Namespace CSharp-Specialized-Namespace CSharp-Specialized-StringCollection +1 More Similar Reads C# | Copy the elements of a string array to the end of the StringCollection 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 en 2 min read C# | Check if the specified string is in the StringCollection 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.Contains(String) method is used to check whether the specified string is in the St 2 min read How to create a StringCollection in C# StringCollection() constructor is used to initializing a new instance of the StringCollection class. 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 2 min read C# | Copy StringCollection at the specified index of array 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.CopyTo(String[], Int32) method is used to copy the entire StringCollection values 3 min read C# | Remove from the specified index of the StringCollection 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 3 min read C# | Remove all the strings from the StringCollection 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.Clear method is used to remove all the strings from the StringCollection. Syntax: 2 min read Like