KeyedCollection<TKey,TItem>.TryGetValue(TKey, TItem) Method

Definition

Tries to get an item from the collection using the specified key.

public bool TryGetValue (TKey key, out TItem item);

Parameters

key
TKey

The key of the item to search in the collection.

item
TItem

When this method returns true, the item from the collection that matches the provided key; when this method returns false, the default value for the type of the collection.

Returns

true if an item for the specified key was found in the collection; otherwise, false.

Exceptions

key is null.

Applies to

Product Versions
.NET Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Standard 2.1