Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CharEnumerator::Clone Method ()

 

Creates a copy of the current CharEnumerator object.

Namespace:   System
Assembly:  mscorlib (in mscorlib.dll)

public:
virtual Object^ Clone() sealed

Return Value

Type: System::Object^

An Object that is a copy of the current CharEnumerator object.

The return value is a copy of this instance of CharEnumerator and its current state. This is useful for saving your state while iterating through a String object.

For example, suppose your application uses an original instance of CharEnumerator to iterate through each character in a String. When some unique character is encountered, your application pauses processing and invokes the Clone method. In effect, this saves the CharEnumerator object's index in the String.

Your application uses the clone to navigate to another part of the String to perform some auxiliary processing. The side-effect of this navigation is the clone loses track of the position where processing stopped. However, when the auxiliary processing is complete, your application discards the clone and uses the original CharEnumerator instance to resume working on the String where the original processing stopped.

System_CAPS_noteNote

This method is implemented to support the ICloneable interface.

.NET Framework
Available since 1.1
Return to top
Show:
© 2017 Microsoft