C# 中 CharEnumerator.ToString() 方法
C# 中的 CharEnumerator.ToString() 方法获取一个表示当前对象的字符串。
语法
以下是语法 -
public virtual string ToString();
示例
现在我们来看一个实现 CharEnumerator.ToString() 方法的示例 -
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());
Console.WriteLine("
String representation = "+ch.ToString());
while (ch.MoveNext())
Console.Write(ch.Current + " ");
ch.Reset();
Console.WriteLine();
while (ch.MoveNext())
Console.Write(ch.Current);
}
}输出
这将产生以下输出 -
HashCode = 31020903 Get the Type = System.CharEnumerator String representation = System.CharEnumerator T h i s i s i t ! This is it!
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP