What is the Literals in C#

In this article we are going to learn about the Literals in C# and their kinds.
  • 2135


The literal means a notation i.e. referred a value in the memory with identifier and source code. There is slightly logical difference between literal string and literal value.

Example of literal given below

"hello"  (string);  This is a strung type literal.
 true       (A boolen); This is a boolen type literal.
 3.14      (A real number); This is a real number type literal.
[1,2,3]    A list of numbers.

Literal value

In programming language a character is a value literal, in C# programming character literal are enclosed with the singal-quta's and value are encapsulated with the backlash characters. The variables that store the value can simply change there location but character literal is still.

Example of value literal

char literal1 = 'b';

© 2019 DotNetHeaven. All rights reserved.