Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

CharEnumerator.GetType() วิธีการใน C #


CharEnumerator.GetType() วิธีการใน C# ใช้เพื่อรับชนิดของอินสแตนซ์ปัจจุบัน

ไวยากรณ์

public Type GetType();

ให้เรามาดูตัวอย่างการใช้เมธอด CharEnumerator.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 + " ");
      // disposed
      ch.Dispose();
      // this will show an error since we disposed the object above
      // Console.WriteLine(ch.Current);
   }
}

ผลลัพธ์

สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -

HashCode = 1373506
Get the Type = System.CharEnumerator
j o h n