C#의 CharEnumerator.Reset() 메서드는 열거된 문자열의 첫 번째 문자보다 논리적으로 앞의 위치로 인덱스를 초기화합니다.
구문
public void Reset ();
예시
이제 CharEnumerator.Reset() 메서드를 구현하는 예를 살펴보겠습니다. -
using System;
public class Demo {
public static void Main(){
string strNum = "This is it!";
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 ! This is it!