CharEnumerator.MoveNext() วิธีการใน C # ถูกใช้เพื่อเพิ่มดัชนีภายในของวัตถุ CharEnumerator ปัจจุบันเป็นอักขระถัดไปของสตริงที่แจกแจง
ไวยากรณ์
public bool MoveNext ();
ให้เราดูตัวอย่างการใช้วิธี CharEnumerator.MoveNext() -
ตัวอย่าง
using System;
public class Demo {
public static void Main(){
string strNum = "john";
CharEnumerator ch = strNum.GetEnumerator();
Console.WriteLine("HashCode = "+ch.GetHashCode());
Console.WriteLine("Get the Type = "+ch.GetType());
while (ch.MoveNext())
Console.Write(ch.Current + " ");
// disposed
ch.Dispose();
// this will show an error since we disposed the object above
// Console.WriteLine(ch.Current);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
HashCode = 1373506 Get the Type = System.CharEnumerator j o h n