ConcurrentBag<T>.IProducerConsumerCollection<T>.TryAdd(T) ConcurrentBag<T>.IProducerConsumerCollection<T>.TryAdd(T) ConcurrentBag<T>.IProducerConsumerCollection<T>.TryAdd(T) Method

定義

嘗試將物件加入至 ConcurrentBag<T>Attempts to add an object to the ConcurrentBag<T>.

 virtual bool System.Collections.Concurrent.IProducerConsumerCollection<T>.TryAdd(T item) = System::Collections::Concurrent::IProducerConsumerCollection<T>::TryAdd;
bool IProducerConsumerCollection<T>.TryAdd (T item);
Function TryAdd (item As T) As Boolean Implements IProducerConsumerCollection(Of T).TryAdd

參數

item
T T T

要加入 ConcurrentBag<T> 的物件。The object to be added to the ConcurrentBag<T>. 值可以是參考型別的 null 參考 (在 Visual Basic 中為 Nothing)。The value can be a null reference (Nothing in Visual Basic) for reference types.

傳回

一律傳回 trueAlways returns true

實作

適用於

另請參閱