Export (0) Print
Expand All

CharEnumerator.Clone Method

Creates a copy of the current CharEnumerator object.

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

public Object Clone()

Return Value

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

Implements

ICloneable.Clone()

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.

NoteNote

This method is implemented to support the ICloneable interface.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft