Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

C# | CharEnumerator.GetType() Method

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

CharEnumerator.GetType() Method is used to get the type of the current instance. This method is inherited from the Object Class.

Syntax:

public Type GetType();

Return Value: This method returns the exact runtime type of the current instance.

Below are the programs to illustrate the use of CharEnumerator.GetType() Method:+

Example 1:




// C# program to illustrate the
// use of CharEnumerator.GetType()
// 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.GetType());
    }
}

Output:

System.CharEnumerator

Example 2:




// C# program to illustrate the
// use of CharEnumerator.GetType()
// Method
using System;
  
class GFG {
  
    // Driver code
    public static void Main()
    {
        // Initialize a string object
        string str = "GeeksforGeeks is fun";
  
        // 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.GetType());
  
        Console.WriteLine("Type of CharEnumerator clone object: " 
                                        + chEnumClone.GetType());
    }
}

Output:

Type of CharEnumerator object: System.CharEnumerator
Type of CharEnumerator clone object: System.CharEnumerator

My Personal Notes arrow_drop_up
Last Updated : 30 Apr, 2019
Like Article
Save Article
Similar Reads