KeyedCollection<TKey,TItem>.TryGetValue(TKey, TItem) 方法

定义

尝试使用指定的键从集合中获取项。

public:
 bool TryGetValue(TKey key, [Runtime::InteropServices::Out] TItem % item);
public bool TryGetValue(TKey key, out TItem item);
member this.TryGetValue : 'Key * 'Item -> bool
Public Function TryGetValue (key As TKey, ByRef item As TItem) As Boolean

参数

key
TKey

在集合中搜索的项的键。

item
TItem

此方法返回 true时,与提供的键匹配的集合中的项;此方法返回 false时, default 集合类型的值。

返回

true 如果在集合中找到指定键的项,则为 ;否则,为 false.

例外

keynull

适用于