C# | CharEnumerator.ToString() Method

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:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

System.String

Example 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

Type of CharEnumerator Object: System.String
Type of CharEnumerator clone Object: System.String


My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.