ชนิดยาวแสดงถึงจำนวนเต็มที่ลงนาม 64 บิต
ในการแปลงจำนวนเต็มที่ลงนาม 64 บิตเป็นทศนิยมโดยปริยาย ก่อนอื่นให้ตั้งค่าแบบยาว
long val = 989678876876876;
หากต้องการแปลงค่ายาวเป็นทศนิยม ให้กำหนดค่า
dec = val;
เรามาดูตัวอย่างกัน −
ตัวอย่าง
using System;
public class Demo {
public static void Main() {
long val = 76755565656565;
decimal dec;
Console.WriteLine("Implicit conversion from 64-bit signed integer (long) to Decimal");
dec = val;
Console.WriteLine("Decimal : "+dec);
}
} ผลลัพธ์
Implicit conversion from 64-bit signed integer (long) to Decimal Decimal : 76755565656565