Mono Class Library: System.Collections.IList Overview | Members

System.Collections.IList.IsReadOnly Property

Gets a value indicating whether the current instance is read-only. [Edit]

public bool IsReadOnly { get; }

Value

true if the current instance is read-only; otherwise, false. [Edit]

Remarks

This property is read-only.

Note: A collection that is read-only does not allow the modification, addition, or removal of elements.

Operation
Any method that modifies, adds, or removes an element of a collection is required to check the value of this property for the particular collection before executing. If the value of this property is false, any attempt to modify, add, or remove an element of the current instance is required to throw a NotSupportedException.

The default of this property is false.

Note to Inheritors
Override this property, setting the value to true, in order to prevent the modification, addition, or removal of elements in the current instance.

Usage
Use IList.IsReadOnly to secure the current instance from modification from methods, such as IList.Add(object) and IList.Remove(object), which modify, add, or remove elements from a list.

[Edit]

Requirements

Namespace: System.Collections
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0