ReadOnlyDictionary<TKey,TValue>.TryGetValue(TKey, TValue) 方法

定义

检索与指定键关联的值。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

将检索其值的键。The key whose value will be retrieved.

value
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.

返回

Boolean

如果实现 ReadOnlyDictionary<TKey,TValue> 的对象包含具有指定键的元素,则为 true;否则,为 falsetrue if the object that implements ReadOnlyDictionary<TKey,TValue> contains an element with the specified key; otherwise, false.

实现

适用于