C# 中 CharEnumerator.MoveNext() 方法
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();
// 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
广告
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP