Open In App

C# | CharEnumerator.ToString() Method

Last Updated : 11 Jul, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report
CharEnumerator.ToString() Method is used to get a string that represents the current object. It is inherited from the Object Class. Syntax:
public virtual string ToString();
Return Value: This method returns a string which represents the current CharEnumerator object. Below are the programs to illustrate the use of CharEnumerator.ToString() Method: Example 1: csharp
// C# program to illustrate the
// use of CharEnumerator.ToString()
// Method
using System;

class GFG {

    // Driver code
    public static void Main()
    {
        // Initialize a string object
        string str = "GeeksforGeeks is Awesome!!";

        // Instantiate a CharEnumerator object
        CharEnumerator chEnum = str.GetEnumerator();

        // Printing the Type of
        // the CharEnumerator objects
        Console.WriteLine(chEnum.ToString().GetType());
    }
}
Output:
System.String
Example 2: csharp
// C# program to illustrate the
// use of CharEnumerator.ToString()
// Method
using System;

class GFG {

    // Driver code
    public static void Main()
    {
        // Initialize a string object
        string str = "GeeksforGeeks Ranking - 50!";

        // Instantiate a CharEnumerator object
        CharEnumerator chEnum = str.GetEnumerator();

        // Instantiate a clone of CharEnumerator object
        CharEnumerator chEnumClone = (CharEnumerator)chEnum.Clone();

        // Printing the Type of the
        // CharEnumerator objects 
        // and its clone
        Console.WriteLine("Type of CharEnumerator Object: " +
                                 chEnum.ToString().GetType());
                                 
        Console.WriteLine("Type of CharEnumerator clone Object: " +
                                 chEnumClone.ToString().GetType());
    }
}
Output:
Type of CharEnumerator Object: System.String
Type of CharEnumerator clone Object: System.String

Similar Reads