ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly ICollection<T>.IsReadOnly Property

定义

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

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

属性值

如果 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. 例如, IsReadOnly强制转换或转换ICollection<T>为对象的数组的属性将返回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.

适用于