What are integer literals in C#?


An integer literal can be a decimal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, and there is no prefix id for decimal. It can also have a suffix that is a combination of U and L, for unsigned and long, respectively.

Here are some of the examples of integer literals −

200 // int
90u// unsigned int

Let’s use the above literal while declaring and initializing a variable −

// int
int a =200;

We will now print the values −

Example

 Live Demo

using System;

namespace Demo {

   class Program {

      static void Main(string[] args) {

         // integer literal
         int a = 200;
         Console.WriteLine(a);

      }
   }
}

Output

200

Updated on: 20-Jun-2020

374 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements