C# में CharEnumerator.MoveNext() मेथड का उपयोग वर्तमान CharEnumerator ऑब्जेक्ट के आंतरिक इंडेक्स को गणना की गई स्ट्रिंग के अगले वर्ण पर बढ़ाने के लिए किया जाता है।
सिंटैक्स
public bool MoveNext ();
आइए CharEnumerator.MoveNext() मेथड को लागू करने का एक उदाहरण देखते हैं -
उदाहरण
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();
// यह त्रुटि दिखाएगा क्योंकि हमने ऊपर ऑब्जेक्ट को डिस्पोज़ कर दिया है
// Console.WriteLine(ch.Current);
}
}
आउटपुट
यह निम्नलिखित आउटपुट देगा -
HashCode = 1373506 Get the Type = System.CharEnumerator j o h n