📜  C#| CharEnumerator.GetType()方法

📅  最后修改于: 2021-05-30 01:25:42             🧑  作者: Mango

CharEnumerator.GetType()方法用于获取当前实例的类型。此方法是从Object类继承的。

句法:

public Type GetType();

返回值:该方法返回当前实例的确切运行时类型。

下面是说明CharEnumerator.GetType()方法用法的程序:+

范例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());
    }
}
输出:
System.CharEnumerator

范例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());
    }
}
输出:
Type of CharEnumerator object: System.CharEnumerator
Type of CharEnumerator clone object: System.CharEnumerator