C#中的CharEnumerator.Reset()方法在逻辑上将索引初始化到枚举字符串的第一个字符之前的位置。
public void Reset ();
现在让我们看一个实现CharEnumerator.Reset()方法的示例-
using System;
public class Demo {
public static void Main(){
string strNum = "就是这个!";
CharEnumerator ch = strNum.GetEnumerator();
Console.WriteLine("HashCode = "+ch.GetHashCode());
Console.WriteLine("Get the Type = "+ch.GetType());
while (ch.MoveNext())
Console.Write(ch.Current + " ");
ch.Reset();
Console.WriteLine();
while (ch.MoveNext())
Console.Write(ch.Current);
}
}输出结果
这将产生以下输出-
HashCode = 65311716 Get the Type = System.CharEnumerator T h i s i s i t ! 就是这个!