เมธอด CharEnumerator.GetType() ใน C# ดึงประเภท (Type) ของอินสแตนซ์ปัจจุบัน
ไวยากรณ์
public Type GetType();
ตัวอย่าง
using System;
public class Demo
{
public static void Main()
{
string strNum = "john";
CharEnumerator ch = strNum.GetEnumerator();
Console.WriteLine("HashCode = " + ch.GetHashCode());
Console.WriteLine("Get the Type = " + ch.GetType());
while (ch.MoveNext())
Console.Write(ch.Current + " ");
ch.Dispose();
}
}
ผลลัพธ์
HashCode = 1373506
Get the Type = System.CharEnumerator
j o h n
หมายเหตุ: นี่คือเมธอดมาจาก System.Object คืนค่า System.CharEnumerator เสมอ