ImmutableSortedDictionary<TKey,TValue>.TryGetKey(TKey, TKey) 方法

定义

确定此字典是否包含指定的键。Determines whether this dictionary contains a specified key.

public:
 virtual bool TryGetKey(TKey equalKey, [Runtime::InteropServices::Out] TKey % actualKey);
public bool TryGetKey (TKey equalKey, out TKey actualKey);
abstract member TryGetKey : 'Key * 'Key -> bool
override this.TryGetKey : 'Key * 'Key -> bool
Public Function TryGetKey (equalKey As TKey, ByRef actualKey As TKey) As Boolean

参数

equalKey
TKey

要搜索的键。The key to search for.

actualKey
TKey

如果已在字典中找到匹配键,则为该匹配键;如果找不到任何匹配键,则为 equalkeyThe matching key located in the dictionary if found, or equalkey if no match is found.

返回

Boolean

如果找到了 equalKey 的匹配项,则为 true;否则为 falsetrue if a match for equalKey is found; otherwise, false.

实现

注解

下面是一些 TryGetKey 可能有用的方案: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

适用于