CharEnumerator.Clone CharEnumerator.Clone CharEnumerator.Clone CharEnumerator.Clone Method

定义

创建当前 CharEnumerator 对象的副本。Creates a copy of the current CharEnumerator object.

public:
 virtual System::Object ^ Clone();
public object Clone ();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object

返回

Object,是当前 CharEnumerator 对象的副本。An Object that is a copy of the current CharEnumerator object.

实现

注解

返回值是此实例的CharEnumerator副本及其当前状态。The return value is a copy of this instance of CharEnumerator and its current state. 这对于在遍历String对象时保存状态很有用。This is useful for saving your state while iterating through a String object.

例如, 假设应用程序使用的原始实例CharEnumerator来循环访问中的String每个字符。For example, suppose your application uses an original instance of CharEnumerator to iterate through each character in a String. 当遇到一些唯一字符时, 应用程序会暂停处理并调用Clone方法。When some unique character is encountered, your application pauses processing and invokes the Clone method. 实际上, 这会将CharEnumerator String对象的索引保存在中。In effect, this saves the CharEnumerator object's index in the String.

应用程序使用该克隆导航到的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. 不过, 辅助处理完成后, 应用程序会丢弃克隆, 并使用原始CharEnumerator实例继续处理原始处理停止的String位置。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.

备注

实现此方法是为了支持ICloneable接口。This method is implemented to support the ICloneable interface.

适用于