Use the IsFixedSize property in C# to get a value indicating whether the SortedList has a fixed size.
The following is an example showing SorteList with the usage of IsFixedSize property.
Example
using System;
using System.Collections;
namespace Demo {
class Program {
static void Main(string[] args) {
SortedList s = new SortedList();
s.Add("S1", "Maths");
s.Add("S2", "Science");
s.Add("S3", "English");
s.Add("S4", "Economics");
Console.WriteLine("IsFixedSize = " + s.IsFixedSize);
}
}
}Output
IsFixedSize = False
We have added a SortedList first and then used the Add() method to set the elements with key and value pair.
SortedList s = new SortedList();
s.Add("S1", "Maths");
s.Add("S2", "Science");
s.Add("S3", "English");
s.Add("S4", "Economics");Now we have used the IsFixedSize above to check whether the size of the SortedList is fixed or not.