CharEnumerator.GetHashCode() วิธีการใน C# ส่งกลับรหัสแฮชสำหรับวัตถุปัจจุบัน
ไวยากรณ์
public virtual int GetHashCode ();
ให้เรามาดูตัวอย่างการใช้เมธอด CharEnumerator.GetHashCode() -
ตัวอย่าง
using System;
public class Demo {
public static void Main(){
string strNum = "john";
CharEnumerator ch = strNum.GetEnumerator();
Console.WriteLine("HashCode = "+ch.GetHashCode());
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 = 30571253 j o h n