Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Phương thức CharEnumerator.GetType() trong C#

Phương thức CharEnumerator.GetType() trong C# được dùng để lấy kiểu (Type) của thể hiện hiện tại.

Cú pháp

public Type GetType();

Ví dụ

using System;
public class Demo {
    public static void Main() {
        string strNum = "john";
        CharEnumerator ch = strNum.GetEnumerator();
        Console.WriteLine("HashCode = " + ch.GetHashCode());
        Console.WriteLine("Lấy Type = " + ch.GetType());
        while (ch.MoveNext())
            Console.Write(ch.Current + " ");
        ch.Dispose();
    }
}

Kết quả

HashCode = 1373506
Lấy Type = System.CharEnumerator
j o h n