C#中的CharEnumerator.GetType()方法用于获取当前实例的类型。
public Type GetType();
现在让我们看一个实现CharEnumerator.GetType()方法的示例-
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