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

適用於