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

定義

嘗試將物件加入至 IProducerConsumerCollection<T>Attempts to add an object to the IProducerConsumerCollection<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

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

傳回

如果物件加入成功則為 true,否則為 false。true if the object was added successfully; otherwise, false.

實作

備註

對於ConcurrentQueue<T>, 這項作業一律會將物件加入至的結尾ConcurrentQueue<T> , 並傳回 true。For ConcurrentQueue<T>, this operation will always add the object to the end of the ConcurrentQueue<T> and return true.

適用於

另請參閱