Literals are hard coded value to a certain type.
For example, 0
is a literal for int
type.
The following code uses int
literal to initialize an int
type variable.
using System;
class Program
{
static void Main(string[] args)
{
int i = 5;
Console.WriteLine(i);
}
}
The output:
5
We can also use hexidecimal literal in C#.
The hexidecimal has 0X
prefix.
using System;
class Program
{
static void Main(string[] args)
{
int i = 0XFF;
Console.WriteLine(i);
}
}
The output:
255
java2s.com | Contact Us | Privacy Policy |
Copyright 2009 - 12 Demo Source and Support. All rights reserved. |
All other trademarks are property of their respective owners. |