Partilhar via


Set.elements Method

Definition

Returns the number of elements in the set.

public:
 int elements();
public int elements ();
member this.elements : unit -> int
Public Function elements () As Integer

Returns

The number of elements in the set.

Remarks

The following example packs the contents of a set into a container. The elements method is used to test whether the set has any contents. If there are no contents, a nullNothingnullptrunita null reference (Nothing in Visual Basic) container is returned.

public static container intSet2Con(Set _intSet) 
{ 
    SetEnumerator se; 
    container     intCon; 
    ; 
    if (!_intSet || !_intSet.elements()) 
    { 
        return conNull(); 
    } 
    se = _intSet.getEnumerator(); 
    while (se.moveNext()) 
    { 
        intCon += se.current(); 
    } 
    return intCon; 
}

Applies to