ประเภท ulong แทนจำนวนเต็ม 64 บิต ที่ไม่มีเครื่องหมาย คือ UInt64
เพื่อแปลงนัยโดยนัยจำนวนเต็ม 64 บิต ไม่มีเครื่องหมาย เป็น Decimal ขั้นแรกให้กำหนดค่า UInt64:
ulong val = ulong.MaxValue;
เพื่อแปลง ulong เป็น decimal ให้กำหนดค่า:
decimal dec; dec = val;
มาดูตัวอย่างข้างต้น
ตัวอย่าง
using System;
public class Demo
{
public static void Main()
{
ulong val = ulong.MaxValue;
decimal dec;
Console.WriteLine("Implicit conversion from Ulong to Decimal");
dec = val;
Console.WriteLine("Decimal : " + dec);
}
}
ผลลัพธ์
Implicit conversion from Ulong to Decimal
Decimal : 18446744073709551615