ConcurrentDictionary<TKey,TValue>.TryGetValue(TKey, TValue) ConcurrentDictionary<TKey,TValue>.TryGetValue(TKey, TValue) ConcurrentDictionary<TKey,TValue>.TryGetValue(TKey, TValue) ConcurrentDictionary<TKey,TValue>.TryGetValue(TKey, TValue) Method

定义

尝试从 ConcurrentDictionary<TKey,TValue> 获取与指定的键关联的值。 Attempts to get the value associated with the specified key from the ConcurrentDictionary<TKey,TValue>.

public:
 virtual bool TryGetValue(TKey key, [Runtime::InteropServices::Out] TValue % value);
public bool TryGetValue (TKey key, out TValue value);
abstract member TryGetValue : 'Key *  -> bool
override this.TryGetValue : 'Key *  -> bool
Public Function TryGetValue (key As TKey, ByRef value As TValue) As Boolean
参数
key
TKey TKey TKey TKey

要获取的值的键。 The key of the value to get.

value
TValue TValue TValue TValue

当此方法返回时,将包含 ConcurrentDictionary<TKey,TValue> 中具有指定键的对象;如果操作失败,则包含类型的默认值。 When this method returns, contains the object from the ConcurrentDictionary<TKey,TValue> that has the specified key, or the default value of the type if the operation failed.

返回

如果在 ConcurrentDictionary<TKey,TValue> 中找到该键,则为 true;否则为 false true if the key was found in the ConcurrentDictionary<TKey,TValue>; otherwise, false.

实现
异常

适用于

另请参阅