Add Method

HashSet<T>.Add Method

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Adds the specified element to a set.

Namespace:  System.Collections.Generic
Assembly:  System.Core (in System.Core.dll)

public bool Add(
	T item
)

Parameters

item
Type: T
The element to add to the set.

Return Value

Type: System.Boolean
true if the element is added to the HashSet<T> object; false if the element is already present.

Implements

ISet<T>.Add(T)

If Count already equals the capacity of the HashSet<T> object, the capacity is automatically adjusted to accommodate the new item.

If Count is less than the capacity of the internal array, this method is an O(1) operation. If the HashSet<T> object must be resized, this method becomes an O(n) operation, where n is Count.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft