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

Integer Literals ใน C# (ค่าคงที่จำนวนเต็ม)

Integer Literal เป็นค่าคงฐานสิบ (Decimal) หรือฐานสิบหก (Hexadecimal)

  • Prefix 0x หรือ 0X = Hexadecimal
  • ไม่มี Prefix = Decimal
  • Suffix U = Unsigned, L = Long

ตัวอย่าง

200    // int
90u    // unsigned int
30L    // long

การใช้งาน

int a = 200;

ตัวอย่างโค้ด

using System;
namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 200; // Integer literal
            Console.WriteLine(a);
        }
    }
}

Output

200