Phương thức CharEnumerator.MoveNext() trong C# được dùng để tăng chỉ số nội bộ của đối tượng CharEnumerator hiện tại đến ký tự tiếp theo của chuỗi được liệt kê.
Cú pháp
public bool MoveNext();
Ví dụ
using System;
public class Demo {
public static void Main() {
string strNum = "john";
CharEnumerator ch = strNum.GetEnumerator();
Console.WriteLine("HashCode = " + ch.GetHashCode());
Console.WriteLine("Lấy Type = " + ch.GetType());
while (ch.MoveNext())
Console.Write(ch.Current + " ");
// Giải phóng
ch.Dispose();
// Dòng dưới sẽ lỗi vì đối tượng đã bị dispose
// Console.WriteLine(ch.Current);
}
}
Kết quả
HashCode = 1373506 Lấy Type = System.CharEnumerator j o h n