CharEnumerator.Clone 方法

定義

建立目前 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

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. 當您逐一查看物件時,這有助於儲存您的狀態 StringThis is useful for saving your state while iterating through a String object.

例如,假設您的應用程式使用的原始實例 CharEnumerator 逐一查看中的每個字元 StringFor 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 物件的索引儲存在中 StringIn 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.

適用於