HashSet<T>.TryGetValue(T, T) HashSet<T>.TryGetValue(T, T) HashSet<T>.TryGetValue(T, T) HashSet<T>.TryGetValue(T, T) Method

定义

在集内搜索给定的值,并返回所找到的相等值(如果有)。Searches the set for a given value and returns the equal value it finds, if any.

public:
 bool TryGetValue(T equalValue, [Runtime::InteropServices::Out] T % actualValue);
public bool TryGetValue (T equalValue, out T actualValue);
member this.TryGetValue : 'T * 'T -> bool
Public Function TryGetValue (equalValue As T, ByRef actualValue As T) As Boolean

参数

equalValue
T T T T

要搜索的值。The value to search for.

actualValue
T T T T

搜索操作在集内找到的值;如果搜索操作未生成任何匹配项,则返回 T 的默认值。The value from the set that the search found, or the default value of T when the search yielded no match.

返回

一个指示搜索是否成功的值。A value indicating whether the search was successful.

注解

当您想要重用以前存储的引用而不是新构造的引用时,这可能很有用(以便可以进行更多的引用共享)或查找具有比当前值更完整的数据的值,尽管它们的比较器函数指示它们相等。This can be useful when you want to reuse a previously stored reference instead of a newly constructed one (so that more sharing of references can occur) or to look up a value that has more complete data than the value you currently have, although their comparer functions indicate they are equal.

适用于