ภาพรวม
โครงสร้าง UInt64 (unsigned 64-bit integer) มีเมธอด GetTypeCode() คืน TypeCode.UInt64
ตัวอย่างที่ 1: ค่า 55 และ 100
using System;
public class Demo
{
public static void Main()
{
ulong val1 = 55;
ulong 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 = UInt64 Typecode for val2 = UInt64
ตัวอย่างที่ 2: UInt64.MinValue และ 0 (โค้ดต้นฉบับมีบัคใช้ uint แทน ulong)
using System;
public class Demo
{
public static void Main()
{
ulong val1 = UInt64.MinValue; // 0
ulong 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 = UInt64 Typecode for val2 = UInt64
สรุป
GetTypeCode()คืนTypeCode.UInt64สำหรับทุกค่า UInt64- UInt64 ใช้ 8 ไบต์ ช่วง 0 ถึง 18,446,744,073,709,551,615
- โค้ดตัวอย่างที่ 2 เดิมประกาศ
uintแทนulong(已在上面修正)