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

เมธอด UInt32.GetTypeCode() ใน C# พร้อมตัวอย่าง

เมธอด UInt32.GetTypeCode() ใน C# ใช้สำหรับคืนค่า TypeCode สำหรับประเภทค่า UInt32

ไวยากรณ์

ไวยากรณ์มีดังนี้

public TypeCode GetTypeCode ();

ตัวอย่าง

มาดูตัวอย่างการใช้งานเมธอด UInt32.GetTypeCode()

using System; 
public class Demo { 
    public static void Main(){ 
        uint val1 = 55; 
        uint val2 = 100; 
        TypeCode type1 = val1.GetTypeCode(); 
        TypeCode type2 = val2.GetTypeCode(); 
        Console.WriteLine("Typecode for val1 = " + type1); 
        Console.WriteLine("Typecode for val2 = " + type2); 
    } 
}

ผลลัพธ์

Typecode for val1 = UInt32 
Typecode for val2 = UInt32

ตัวอย่างเพิ่มเติม

ตัวอย่างที่สองใช้ UInt32.MinValue และ 0

using System; 
public class Demo { 
    public static void Main(){ 
        uint val1 = UInt32.MinValue; 
        uint val2 = 0; 
        TypeCode type1 = val1.GetTypeCode(); 
        TypeCode type2 = val2.GetTypeCode(); 
        Console.WriteLine("Typecode for val1 = " + type1); 
        Console.WriteLine("Typecode for val2 = " + type2); 
    } 
}

ผลลัพธ์

Typecode for val1 = UInt32 
Typecode for val2 = UInt32