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

CsharpProgrammingServer Side Programming

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
raja
Published on 17-Sep-2018 12:47:31
Advertisements