ICollection<T>.IsReadOnly Property


取得值,該值指出 ICollection<T> 是否為唯讀。Gets a value indicating whether the ICollection<T> is read-only.

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

Property Value


如果 true 為唯讀,即為 ICollection<T>;否則為 falsetrue if the ICollection<T> is read-only; otherwise, false.


唯讀的集合不允許在集合建立之後加入或移除專案。A collection that is read-only does not allow the addition or removal of elements after the collection is created. 請注意,此內容中的唯讀不會指出是否可以修改集合的個別元素,因為 ICollection<T> 介面只支援新增和移除作業。Note that read-only in this context does not indicate whether individual elements of the collection can be modified, since the ICollection<T> interface only supports addition and removal operations. 例如,轉換或轉換成 ICollection<T> 物件之陣列的 IsReadOnly 屬性會傳回 true,即使可以修改個別陣列元素也一樣。For example, the IsReadOnly property of an array that is cast or converted to an ICollection<T> object returns true, even though individual array elements can be modified.

Applies to