This documentation is archived and is not being maintained.

CharEnumerator.MoveNext Method

Increments the index to the next character of the enumerated string.

[Visual Basic]
Public Overridable Function MoveNext() As Boolean Implements _
public virtual bool MoveNext();
public: virtual bool MoveNext();
public function MoveNext() : Boolean;

Return Value

true if the index is successfully incremented and within the enumerated string; otherwise, false.




The MoveNext method increments the index by one. Call MoveNext after calling GetEnumerator or Reset to increment the current character position to the first character in the enumerated string. Check that the return value is true to determine that the current character position is valid.

If the index is already beyond the last character of the enumerated string, the index is not changed and false is returned.

Notice that if the enumerated string is empty (""), the state of the CharEnumerator is always invalid. This is because the internal index for the CharEnumerator is initially before the first character of the enumerated string and is therefore invalid. MoveNext logically sets the index after the last (nonexistent) character of the enumerated string which is also invalid.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework, Common Language Infrastructure (CLI) Standard

See Also

CharEnumerator Class | CharEnumerator Members | System Namespace