C# Literals are value constants assigned to variables in a program. In C#, there are 6 types of literals are exists.
An Integer Literals refers to a sequence of digits. There are two types of integer namely:
Decimal Integers cosists of a set of digits, o to 9 preceded by an optional minus sign.
123, -321, 654321
Hexamdecimal Integers refers to a sequence of digits preceded by 0x or 0X is considered as a Hexamdecimal Integers. It may also include alphabets A, B, C, D, E, F or a, b, c, d, e, f.
0x, 0X2, 0X9F, 0Xbcd
It is represented by numbers containing fractional parts that is called Real Literals.
0.50, 3.14, -0.15
A real literal may also be expressed in exponential notation.
8.16e47, 0.5e+4, -1.5e-1
There are two types of Boolean literals and that are :
Single Character Literals:
A single character literal contains a single character enclosed within a pair of single quote marks.
'5' 'X' ';''' // The character constant '5' isn't the same as the number 5. The last constant in the '' is a blank space.
A string literal is a sequence of characters enclosed between double quotes. The characters may be alphabets, digits, special characters and blank spaces.
"Hello" "Well Done" "X"
Backslash Character Literals:
In C#, there are supports some special backslash character constants that are used in output methods.
1. C# Features
2. Difference Between C++ and C#
3. Difference Between C# and Java
4. .NET Framework
5. Benefits of .NET
6. C# Program Structure
7. C# Command Line Arguments
8. Console.ReadLine() and Console.WriteLine()
9. C# Literals
10. C# Data Types
11. Scope of Variables in C#
12. Boxing and Unboxing in C#
13. C# Operators
14. C# Type Casting