ImmutableDictionary<TKey, TValue>.TryGetKey Method

Determines whether this dictionary contains a specified key.

Namespace:  System.Collections.Immutable
Assembly:  System.Collections.Immutable (in System.Collections.Immutable.dll)

public bool TryGetKey(
	TKey equalKey,
	out TKey actualKey


Type: TKey

The key to search for.

Type: TKey

The matching key located in the dictionary if found, or equalkey if no match is found.

Return Value

Type: System.Boolean
true if a match for equalKey is found; otherwise, false.


IImmutableDictionary<TKey, TValue>.TryGetKey(TKey, TKey)

Following are some scenarios where TryGetKey may be useful:

  • You want to reuse a previously stored object reference instead of creating a new reference.

  • You want to look up the canonical value of an object

  • You want to retrieve more complete data about an object