KeyedCollection<TKey,TItem>.TryGetValue(TKey, TItem) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Tries to get an item from the collection using the specified key.
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
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
.