C#中的CharEnumerator.GetHashCode()方法
C#中的CharEnumerator.GetHashCode()方法返回当前对象的哈希码。
语法
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 + " ");
//处置
ch.Dispose();
// this will show an error since we处置 the object above
//Console.WriteLine(ch.Current);
}
}输出结果
这将产生以下输出-
HashCode = 30571253 j o h n