ConcurrentStack<T>.IsEmpty 屬性

定義

取得值,這個值指出 ConcurrentStack<T> 是否是空的。

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

屬性值

Boolean

如果 true 是空的,則為 ConcurrentStack<T>,否則為 false

備註

若要判斷集合是否包含任何專案,建議使用此屬性,而不是從 Count 屬性擷取專案數目,並將它與 0 進行比較。 不過,由於此集合的目的是要同時存取,因此,另一個執行緒會在傳回之後 IsEmpty 修改集合,因而使結果失效。

如需程式碼範例,請參閱ConcurrentStack<T>

適用於

另請參閱