Determines if this set contains an item equal to item, according to the
comparison mechanism that was used when the set was created. The set
is not changed.
If the set does contain an item equal to item, then the item from the set is returned.
Namespace: X3Platform.CollectionsAssembly: X3Platform.Support (in X3Platform.Support.dll) Version: 1.0.0.0 (2.0.0.0)
Syntaxpublic bool TryGetItem(
T item,
out T foundItem
)
public:
bool TryGetItem(
T item,
[OutAttribute] T% foundItem
)
Parameters
- item
- Type: T
The item to search for. - foundItem
- Type: T
Returns the item from the set that was equal to item.
Return Value
Type:
BooleanTrue if the set contains
item. False if the set does not contain
item.
RemarksSearching the set for an item takes approximately constant time, regardless of the number of items in the set.
Examples
In the following example, the set contains strings which are compared in a case-insensitive manner.
Set<string> set = new Set<string>(StringComparer.CurrentCultureIgnoreCase);
set.Add("HELLO");
string s;
bool b = set.TryGetItem("Hello", out s);
See Also