C# | CharEnumerator.ToString() Method
Last Updated :
30 Apr, 2019
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:
using System;
class GFG {
public static void Main()
{
string str = "GeeksforGeeks is Awesome!!" ;
CharEnumerator chEnum = str.GetEnumerator();
Console.WriteLine(chEnum.ToString().GetType());
}
}
|
Example 2:
using System;
class GFG {
public static void Main()
{
string str = "GeeksforGeeks Ranking - 50!" ;
CharEnumerator chEnum = str.GetEnumerator();
CharEnumerator chEnumClone = (CharEnumerator)chEnum.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
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...