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
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