CharEnumerator.ToString() Method in C#


The CharEnumerator.ToString() method in C# gets a string that represents the current object.

Syntax

Following is the syntax -

public virtual string ToString();

Example

Let us now see an example to implement the CharEnumerator.ToString() method −

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);    } }

Output

This will produce the following output −

HashCode = 31020903
Get the Type = System.CharEnumerator
String representation = System.CharEnumerator
T h i s i s i t !
This is it!

Updated on: 05-Nov-2019

36 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements