Phương thức CharEnumerator.Reset () trong C # khởi tạo chỉ mục đến một vị trí hợp lý trước ký tự đầu tiên của chuỗi được liệt kê.
Cú pháp
public void Reset ();
Ví dụ
Bây giờ chúng ta hãy xem một ví dụ để triển khai phương thức CharEnumerator.Reset () -
using System;
public class Demo {
public static void Main(){
string strNum = "This is it!";
CharEnumerator ch = strNum.GetEnumerator();
Console.WriteLine("HashCode = "+ch.GetHashCode());
Console.WriteLine("Get the Type = "+ch.GetType());
while (ch.MoveNext())
Console.Write(ch.Current + " ");
ch.Reset();
Console.WriteLine();
while (ch.MoveNext())
Console.Write(ch.Current);
}
} Đầu ra
Điều này sẽ tạo ra kết quả sau -
HashCode = 65311716 Get the Type = System.CharEnumerator T h i s i s i t ! This is it!