C# | Get the number of strings in StringCollection Last Updated : 01 Feb, 2019 Comments Improve Suggest changes 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.Count property is used to get the number of strings contained in the StringCollection. Syntax: public int Count { get; } Return Value: It returns the number of strings contained in the StringCollection. Note: Retrieving the value of this property is an O(1) operation. Below programs illustrate the use of StringCollection.Count Property: Example 1: CSHARP // C# code to get the number of strings // contained in 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(); // creating a string array named myArr String[] myArr = new String[] { "First", "Second", "Third", "Fourth", "Fifth" }; // Copying the elements of a string // array to the end of the StringCollection. myCol.AddRange(myArr); // To get number of Strings contained // in the StringCollection Console.WriteLine("Number of strings in myCol are : " + myCol.Count); } } Output: Number of strings in myCol are : 5 Example 2: CSHARP // C# code to get the number of strings // contained in 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(); // creating a string array named myArr String[] myArr = new String[] {}; // Copying the elements of a string // array to the end of the StringCollection. myCol.AddRange(myArr); // To get number of Strings contained // in the StringCollection Console.WriteLine("Number of strings in myCol are : " + myCol.Count); } } Output: Number of strings in myCol are : 0 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.collections.specialized.stringcollection.count?view=netframework-4.7.2 Comment More infoAdvertise with us Next Article C# | Get the number of strings in StringCollection S Sahil_Bansall Follow Improve Article Tags : C# CSharp-Collections-Namespace CSharp-Specialized-Namespace CSharp-Specialized-StringCollection Similar Reads 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 C# | Get the number of key/value pairs in the StringDictionary StringDictionary.Count property is used to get the number of key/value pairs in the StringDictionary. Syntax: public virtual int Count { get; } Return Value: It returns the number of key/value pairs in the StringDictionary. Note: Retrieving the value of this property is an O(1) operation. Below prog 2 min read C# | Check if StringCollection is synchronized (thread safe) 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.IsSynchronized property is used to get a value indicating whether access to the St 1 min read C# | Insert at the specified index in 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.Insert(Int32, String) method is used to insert a string into the StringCollection 2 min read C# | Index of first occurrence in 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.IndexOf(String) method is used to search the specified string which returns the ze 2 min read C# | Check if the StringCollection is read-only 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.IsReadOnly property is used to get a value indicating whether the StringCollection 1 min read C# | Get the number of elements in the SortedSet SortedSet class represents the collection of objects in sorted order. This class comes under the System.Collections.Generic namespace. SortedSet<T>.Count Property is used to get the number of elements in the SortedSet. Properties: In C#, SortedSet class can be used to store, remove or view elemen 2 min read C# | Remove the first occurrence 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.Remove(String) method is used to remove the first occurrence of a specific string 3 min read C# | Get or Set at specified index in 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. Properties: StringCollection accepts null as a valid value and allows duplicate elements. String co 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 Like