C# | Check if a SortedList object has a fixed size (original) (raw)

Last Updated : 01 Feb, 2019

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.IsFixedSize property is used to check whether a SortedList object has a fixed size or not.Properties of SortedList:

Syntax:

public virtual bool IsFixedSize { get; }

Return Value: This property returns True if the SortedList object has a fixed size, otherwise it returns False. The default value of this property is False.Example:

CSHARP `

// C# code to check if a SortedList // object has a fixed size using System; using System.Collections;

class GFG {

// Driver code
public static void Main()
{

    // Creating an SortedList
    SortedList mySortedList = new SortedList();

    // Adding elements to SortedList
    mySortedList.Add("1", "one");
    mySortedList.Add("2", "two");
    mySortedList.Add("3", "three");
    mySortedList.Add("4", "four");
    mySortedList.Add("5", "five");

    // Checking if a SortedList
    // object has a fixed size
    Console.WriteLine(mySortedList.IsFixedSize);
}

}

`

Output:

False

Note: