SortedList IsReadOnly Property in C# – Programming, Pseudocode Example, C# Programming Example
C# C# Console Collection

SortedList IsReadOnly Property in C#

SortedList class is a collection of (key, value) pairs which are sorted according to keys. Those pairs can be accessible by key and as well as by index(zero-based indexing). This comes under System.Collections namespace.
SortedList.IsReadOnly property is used to get a value which indicates that a SortedList object is read-only or not.

Properties of SortedList:

  • Internally the object of SortedList maintain the two arrays. The first array is used to store the elements of the list i.e. keys and the second one is used to store the associated values.
  • A key cannot be null but value can be.
  • As SortedList used sorting which makes it slower in comparison to Hashtable.
  • The capacity of a SortedList can be dynamically increased through reallocation.
  • The keys in the SortedList cannot be duplicated but values can be.
  • The SortedList can be sorted according to the keys using the IComparer(Either in ascending or descending order).

Example:

Output:

false

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: