วิธี Char.GetTypeCode() ใน C # ใช้เพื่อส่งคืน TypeCode สำหรับประเภทค่า Char
ไวยากรณ์
ต่อไปนี้เป็นไวยากรณ์ -
public TypeCode GetTypeCode ();
ตัวอย่าง
ให้เรามาดูตัวอย่างการใช้เมธอด Char.GetTypeCode() -
using System;
public class Demo {
public static void Main(){
char val = '5';
bool res;
Console.WriteLine("Hashcode for val = "+val.GetHashCode());
res = val.Equals('m');
Console.WriteLine("Return Value = "+res);
Console.WriteLine("Numeric Value = "+Char.GetNumericValue(val));
TypeCode type = val.GetTypeCode();
Console.WriteLine("Type = "+type);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
Hashcode for val = 3473461 Return Value = False Numeric Value = 5 Type = Char
ตัวอย่าง
เรามาดูตัวอย่างอื่นกัน −
using System;
public class Demo {
public static void Main(){
char val = 'B';
TypeCode type = val.GetTypeCode();
Console.WriteLine("Type = "+type);
}
} ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
Type = Char