Array.IsReadOnly Array.IsReadOnly Array.IsReadOnly Array.IsReadOnly Property

定義

取得值,指出 Array 是否唯讀。Gets a value indicating whether the Array is read-only.

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

屬性值

所有陣列的這個屬性永遠為 falseThis property is always false for all arrays.

實作

備註

Array會執行System.Collections.IList屬性, 因為它是介面所需。 IsReadOnlyArray 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.IList介面的類別。If you require a read-only collection, use a System.Collections class that implements the System.Collections.IList interface.

如果您將陣列轉換或轉換為IList介面物件IList.IsReadOnly , 屬性false會傳回。If you cast or convert an array to an IList interface object, the IList.IsReadOnly property returns false. 不過, 如果您將陣列轉換或轉換為IList<T>介面IsReadOnly , 屬性true會傳回。However, 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.

適用於

另請參閱