public sealed class CharEnumerator : ICloneable, IEnumerator
Object
CharEnumeratorThis type implements IEnumerator and ICloneable.
mscorlib
BCL
Supports iteration over and provides read-only access to the individual characters in a String.
[Note: CharEnumerator is used to support theforeach
statement of the C# programming language.Several independent instances of CharEnumerator across one or more threads can have access to a single instance of String.
For more information regarding the use of an enumerator, see IEnumerator.
]
System Namespace
CharEnumerator Methods
CharEnumerator.Clone Method
CharEnumerator.MoveNext Method
CharEnumerator.Reset Method
CharEnumerator Properties
CharEnumerator.Current Property
CharEnumerator.System.Collections.IEnumerator.Current Property
public object Clone();
Creates a copy of the current instance.
A Object with the same state as the current instance.
The return value is a Object containing a copy of the state of the current instance when this method is invoked. This Object must be cast explicitly to a CharEnumerator to be made usable as one.[Note: This method is useful for saving the state of a CharEnumerator object while iterating through the characters of a String .
This method is implemented to support the ICloneable interface.
]
System.CharEnumerator Class, System Namespace
public bool MoveNext();
Advances the current instance to the next element of the String if and only if the current instance is not already placed beyond the final element of the String.
true
if the enumerator was successfully advanced to the next element; otherwise,false
.
If the enumerator is positioned after the final element of the String when this method is called, the current instance remains in its current position andfalse
is returned.
System.CharEnumerator Class, System Namespace
public void Reset();
Repositions the current instance to its initial position, immediately before the first character in the String.
System.CharEnumerator Class, System Namespace
public char Current { get; }
Gets the element in the String over which the current instance is positioned.
The Char in the String over which the current instance is positioned.
Exception Type Condition InvalidOperationException The current instance is positioned before the first element or after the last element of the String.
System.CharEnumerator Class, System Namespace
object IEnumerator.Current { get; }
Implemented to support the IEnumerator interface. [Note: For more information, see System.Collections.IEnumerator.Current.]
System.CharEnumerator Class, System Namespace