ConcurrentStack<T>.IProducerConsumerCollection<T>.TryAdd 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
嘗試將物件加入 IProducerConsumerCollection<T>。
virtual bool System.Collections.Concurrent.IProducerConsumerCollection<T>.TryAdd(T item) = System::Collections::Concurrent::IProducerConsumerCollection<T>::TryAdd;
bool IProducerConsumerCollection<T>.TryAdd(T item);
abstract member System.Collections.Concurrent.IProducerConsumerCollection<T>.TryAdd : 'T -> bool
override this.System.Collections.Concurrent.IProducerConsumerCollection<T>.TryAdd : 'T -> bool
Function TryAdd (item As T) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd
參數
- item
- T
要加入 IProducerConsumerCollection<T>的物件。 這個值可以是空參考(Visual Basic 中為無參考),用於參考型別。
傳回
true如果該物件成功加入;否則,。 false
實作
備註
對於 ConcurrentStack<T>,此操作總是將物件 ConcurrentStack<T> 插入 頂部並返回 true。