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.

傳回

如果在 true 中找到索引鍵,則為 ConcurrentDictionary<TKey,TValue>,否則為 falsetrue if the key was found in the ConcurrentDictionary<TKey,TValue>; otherwise, false.

實作

例外狀況

適用於

另請參閱