Array.IsReadOnly 属性

定义

获取一个值,该值指示 Array 是否为只读。Gets a value indicating whether the Array is read-only.

public:
 property bool IsReadOnly { bool get(); };
public:
 virtual property bool IsReadOnly { bool get(); };
public bool IsReadOnly { get; }
public virtual bool IsReadOnly { get; }
member this.IsReadOnly : bool
Public ReadOnly Property IsReadOnly As Boolean
Public Overridable ReadOnly Property IsReadOnly As Boolean

属性值

Boolean

对于所有数组,此属性始终为 falseThis property is always false for all arrays.

实现

注解

Array 实现 IsReadOnly 属性,因为它是接口所必需的 System.Collections.IListArray implements the IsReadOnly property because it is required by the System.Collections.IList interface. 如果数组为只读,则在创建数组后,不允许添加、移除或修改元素。An array that is read-only does not allow the addition, removal, or modification of elements after the array is created.

如果需要只读集合,请使用 System.Collections 实现接口的类 System.Collections.IListIf you require a read-only collection, use a System.Collections class that implements the System.Collections.IList interface.

如果将数组强制转换或转换为 IList 接口对象,则该 IList.IsReadOnly 属性返回 falseIf you cast or convert an array to an IList interface object, the IList.IsReadOnly property returns false. 但是,如果将数组强制转换或转换为 IList<T> 接口,该 IsReadOnly 属性将返回 trueHowever, if you cast or convert an array to a IList<T> interface, the IsReadOnly property returns true.

检索此属性的值的运算复杂度为 O(1)。Retrieving the value of this property is an O(1) operation.

适用于

另请参阅