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
相關用法
- C# DateTimeOffset.Add()用法及代碼示例
- C# String.Contains()用法及代碼示例
- C# Math.Sin()用法及代碼示例
- C# Math.Cos()用法及代碼示例
- C# Dictionary.Add()用法及代碼示例
- C# Math.Tan()用法及代碼示例
- C# Math.Abs()方法用法及代碼示例
- C# Math.Exp()用法及代碼示例
- C# Math.Abs()函數用法及代碼示例
注:本文由純淨天空篩選整理自rupesh_rao大神的英文原創作品 C# | CharEnumerator.GetType() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。