次の方法で共有


ListIterator.ToString Method

Definition

Returns a textual representation of the current list value that is pointed to by the iterator.

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

Returns

A string that contains a description of the current value.

Remarks

If the iterator points to the first element in the list, the string will contain an indication of this, in the form "(begin)[value]" If the iterator does not point to an element (that is, the more() method returns false), the following string returned is: (end). If the iterator points to a value, the string is "[value]", where value is a string representation of the element value.

The following example prints the following description of the values of the two values in a list:

  1. (begin) [2]

  2. [1]

{ 
    List li = new List(Types::Integer); 
    ListIterator it = new ListIterator(li); 
    li.addStart(1); 
    li.addStart(2); // This is now the first value 
    it.begin(); 
    print it.toString(); 
    it.next(); 
    print it.toString(); 
    pause; 
}

Applies to