Supports iterating over a string object and reading its individual characters. This class cannot be inherited.
See Also: CharEnumerator Members
A CharEnumerator provides read-only access to the characters in a referenced string object. For example, the foreach statement of the Microsoft Visual Basic and C# programming languages, which iterates through the elements of a collection, retrieves a CharEnumerator from a string object in order to iterate through the characters in that object.
A CharEnumerator maintains an internal index to the characters in the string the CharEnumerator references. The state of the index is invalid when it references a character position logically before the first character or after the last character in the string, and valid when it references a character within the string. The index is initialized to a position logically before the first character, and is set to a position after the last character when the iteration is complete. An exception is thrown if you attempt to access a character while the index is invalid.
The CharEnumerator.MoveNext method increments the index by one, so the first and subsequent characters are accessed in turn. The CharEnumerator.Reset method sets the index to a position logically before the first character. The CharEnumerator.Current property retrieves the character currently referenced by index. The CharEnumerator.Clone method creates a copy of the CharEnumerator.