Skip to content
Related Articles
Open in App
Not now

Related Articles

C# | Check if the StringCollection is read-only

Improve Article
Save Article
Like Article
  • Last Updated : 01 Feb, 2019
Improve Article
Save Article
Like Article

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 is read-only or not.


public bool IsReadOnly { get; }

Return Value: This property always returns false.


  • A collection that is read-only does not allow the addition, removal, or modification of elements after the collection is created.
  • Retrieving the value of this property is an O(1) operation.


// C# code to check if the
// StringCollection is read-only
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[] { "A", "B", "C", "D", "E" };
        // Copying the elements of a string
        // array to the end of the StringCollection.
        // checking if StringCollection is
        // read-only




My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!