共用方式為


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) 運算。

適用於

另請參閱