Set.add(Object) Method

Definition

Adds an element to the set.

public:
 bool add(System::Object ^ element);
public bool add (object element);
member this.add : obj -> bool
Public Function add (element As Object) As Boolean

Parameters

element
Object

Returns

true if the element is added to the set; otherwise, false.

Remarks

The element added to a set must be of the same type as the type assigned to the set when it was created. An element will not be added if it already exists in the set.

The following example creates a set, adds some integers to it, and then prints out the contents of the set.

{ 
    // Create a set of integers 
    Set is = new Set (Types::Integer); 
    int i; 
    ;  
    // Add values 0 to 9 to the set 
    for (i = 0; i < 10; i++) 
    { 
        is.add(i); 
    } 
    print is.toString(); 
    pause; 
}

Applies to