CharEnumerator.Reset() วิธีการใน C# เริ่มต้นดัชนีไปยังตำแหน่งอย่างมีเหตุผลก่อนอักขระตัวแรกของสตริงที่แจกแจง
ไวยากรณ์
public void Reset ();
ตัวอย่าง
ให้เราดูตัวอย่างการใช้วิธี 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);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
HashCode = 65311716 Get the Type = System.CharEnumerator T h i s i s i t ! This is it!