Partager via


SetIterator.Value Method

Definition

Retrieves the value that the iterator is pointing to.

public:
 virtual System::Object ^ Value();
public virtual object Value ();
abstract member Value : unit -> obj
override this.Value : unit -> obj
Public Overridable Function Value () As Object

Returns

The value denoted by the iterator.

Remarks

Use SetIterator.more to check whether an element exists before trying to retrieve the key value of the set element.

The following example uses the SetIterator.value method to print the value of the current item in the set.

{ 
    Set s1 = new Set (Types::Integer); 
    SetIterator it; 
    // Add some elements 
    s1.add(3); 
    s1.add(4); 
    s1.add(13); 
    s1.add(1);  
    // Start a traversal of the elements in the set 
    it = new SetIterator(s1); 
    // Prints "(begin)[1]" 
    print it.toString();  
    // The elements are fetched in the order: 1, 3, 4, 13 
    while (it.more()) 
    { 
        print it.value(); 
        // Fetch the next element 
        it.next(); 
    } 
    pause; 
}

Applies to