What is the IsReadOnly property of SortedList class in C#?


Use the IsReadOnly property to get a value indicating whether the SortedList is read-only or not.

You can try to run the following code to implement IsReadOnly property in C#.

Here, we have set the SortedList first.

SortedList s = new SortedList();

Added elements.

s.Add("S001", "Jack");
s.Add("S002", "Henry");

Now check for IsReadOnly.

Console.WriteLine("IsReadOnly = " + s.IsReadOnly);

The following is the complete code.

Example

 Live Demo

using System;
using System.Collections;
namespace Demo {
   class Program {
      static void Main(string[] args) {
         SortedList s = new SortedList();
         s.Add("S001", "Jack");
         s.Add("S002", "Henry");
         Console.WriteLine("IsReadOnly = " + s.IsReadOnly);
      }
   }
}

Output

IsReadOnly = False

Updated on: 23-Jun-2020

54 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements