通过


Array.IsReadOnly 属性

定义

获取一个值,该值指示是否 Array 为只读。

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

属性值

此属性始终 false 适用于所有数组。

实现

注解

Array 实现该 IsReadOnly 属性,因为接口需要 System.Collections.IList 此属性。 只读数组不允许在创建数组后添加、删除或修改元素。

如果需要只读集合,请使用 System.Collections 实现接口的 System.Collections.IList 类。

如果将数组 IList 强制转换或转换为接口对象,则 IList.IsReadOnly 属性返回 false。 但是,如果将数组 IList<T> 强制转换或转换为接口,则 IsReadOnly 属性返回 true

检索此属性的值是 O(1) 操作。

适用于

另请参阅