IProducerConsumerCollection<T>.TryAdd(T) 方法
定义
尝试将一个对象添加到 IProducerConsumerCollection<T> 中。Attempts to add an object to the IProducerConsumerCollection<T>.
public:
bool TryAdd(T item);
public bool TryAdd (T item);
abstract member TryAdd : 'T -> bool
Public Function TryAdd (item As T) As Boolean
参数
- item
- T
要添加到 IProducerConsumerCollection<T> 的对象。The object to add to the IProducerConsumerCollection<T>.
返回
如果成功添加了对象,则为 true;否则为 false。true if the object was added successfully; otherwise, false.
例外
item 对于此集合无效。The item was invalid for this collection.