ConcurrentStack<T>.IsEmpty 属性

定义

获取一个值,该值指示 ConcurrentStack<T> 是否为空。Gets a value that indicates whether the ConcurrentStack<T> is empty.

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

属性值

如果 true 为空,则为 ConcurrentStack<T>;否则为 falsetrue if the ConcurrentStack<T> is empty; otherwise, false.

注解

若要确定集合是否包含任何项,建议使用此属性,而不是检索 Count 属性中的项数并将其与0进行比较。For determining whether the collection contains any items, use of this property is recommended rather than retrieving the number of items from the Count property and comparing it to 0. 但是,因为此集合应同时进行访问,所以,另一个线程可能会在 IsEmpty 返回之后修改集合,从而使结果无效。However, as this collection is intended to be accessed concurrently, it may be the case that another thread will modify the collection after IsEmpty returns, thus invalidating the result.

有关代码示例,请参阅ConcurrentStack<T>For a code example, see ConcurrentStack<T>.

适用于

另请参阅