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

定義

擷取與指定之索引鍵相關聯的值。Retrieves the value that is associated with the specified key.

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

參數

key
TKey TKey TKey TKey

將擷取其值的索引鍵。The key whose value will be retrieved.

value
TValue TValue TValue TValue

這個方法傳回時,如果找到索引鍵,則為與指定索引鍵關聯的值,否則為 value 參數的型別預設值。When this method returns, the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. 這個參數會以未初始化的狀態傳遞。This parameter is passed uninitialized.

傳回

如果實作 ReadOnlyDictionary<TKey,TValue> 之物件包含具有指定索引鍵的元素,則為 true,否則為 falsetrue if the object that implements ReadOnlyDictionary<TKey,TValue> contains an element with the specified key; otherwise, false.

實作

適用於