Gets the currently referenced character in the string enumerated by this CharEnumerator object.
The char in the string over which the current instance is positioned.
Type Reason InvalidOperationException The current instance is positioned before the first element or after the last element of the string.
The CharEnumerator class maintains an internal index to the enumerated string, and the CharEnumerator.Current property returns the character that is currently referenced by the index. This property should be invoked only when the index is valid; otherwise, an exception is thrown.
The index is always invalid for an empty string (""). The index is also invalid after the string.GetEnumerator or CharEnumerator.Reset method is called. After either of these methods is called, invoke the CharEnumerator.MoveNext method to adjust the index to the first character in the enumerated string. The index is valid whenever the CharEnumerator.MoveNext method returns true.
CharEnumerator.Current does not move the index, and consecutive calls to CharEnumerator.Current return the same character until CharEnumerator.MoveNext, CharEnumerator.Reset, or string.GetEnumerator is called.