SlideShare a Scribd company logo
Learn C# Programming
Variables and Constants
Eng Teong Cheah
Microsoft MVP in Visual Studio &
Development Technologies
Agenda
•Variables
•Constants
C# - Variables
C# - Variables
A variable is nothing but a name given to a storage area that our
programs can manipulate. Each variable in C# has a specific type,
which determines the size and layout of the variable’s memory the
range of values that can be stored within that memory and the set of
operations that can be applied to the variable.
C# - Variables
The basic value types provided in C# can be categorized as:
C# - Variables
C# also allows defining other value types of variable such as
enum and reference types of variables such as class, which
we will cover in subsequent chapters.
C# - Variables
Defining Variables
Syntax for variable definition in C# is:
Here, data_type must be a valid C# data type including char,
int, float, double, or any user-defined data type, and
variable_list may consist of one or more identifier names
separated by commas.
<data_type> <variable_list>;
C# - Variables
Defining Variables
Some valid variable definitions are shown here:
int i, j, k;
char c, ch;
float f, salary;
double d;
You can initialize a variable at the time of definition as:
int i = 100;
C# - Variables
Initializing Variables
Variables are initialized (assigned a value) with an equal sign
followed by a constant expression. The general form of
initialization is:
Variables can be initialized in their declaration. The initializer
consists of an equal sign followed by a constant expression
as:
variable_name = value;
<data_type> <variable_name> = value;
C# - Variables
Initializing Variables
Some examples are:
int d = 3, f = 5; /* initializing d and f. */
byte z = 22; /* initializes z. */
double pi = 3.14159; /*declares an approximation of pi. */
char x = ‘x’;
C# - Variables
Initializing Variables
It is a good programming practice to initialize variables
properly, otherwise sometimes program may produce
unexpected result.
Demo
C# - Variables
Accepting Values from User
The Console class in the System namespace provides
function ReadLine() for accepting input from the user and
store it into a variable.
For example,
int num;
num = Convert.ToInt32(Console.ReadLine());
C# - Variables
Accepting Values from User
The function Convert.ToInt32() converts the data entered by
the user to int data type, because Console.ReadLine()
accepts the data in string format.
C# - Variables
Lvalue and Rvalue Expression in C#:
The are two kinds of expressions in C#:
- lvalue: An expression that is an lvalue may appear as either
the left-hand or right-hand side of an assignment.
- rvalue: AN expression that is an rvalue may appear on the
right-hand but not left-hand side of an assignment.
C# - Variables
Lvalue and Rvalue Expression in C#:
Variables are lvalues and hence they may appear on the left-
hand side of an assignment. Numeric literals are rvalues and
hence they may not be assigned and cannot appear on the
left-hand side. Following is a valid C# statement:
int g =20;
C# - Variables
Lvalue and Rvalue Expression in C#:
But following is not a valid statement and would generate
compile-time error:
10 =20;
C# - Constants and
Literals
C# - Constants and Literals
The constants refer to fixed values that the program may not
alter during its execution. These fixed values also called
literals. Constants can be of any of the basic data types like
an integer constant, a floating constant, a character
constant, or a string literal. There are also enumeration
constant as well.
C# - Constants and Literals
The constants are treated just like regular variables except
that their values cannot be modified after their definition.
C# - Constants and Literals
Integer Literals
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.
An integer literal can also have a suffix that is a combination
of U and L, for unsigned and long, respectively. The suffix
can be uppercase or lowercase and can be in any order.
C# - Constants and Literals
Integer Literals
Here are some examples of integer literals:
212 /*Legal*/
215u /*Legal*/
0xFeeL /*Legal*/
C# - Constants and Literals
Integer Literals
Following are other examples of various types of Integer
literals:
85 /*decimal*/
0x4b /*hexadecimal*/
30 /*int*/
30u /*unsigned int*/
301 /*long*/
30u1 /*unsigned long*/
C# - Constants and Literals
Integer Literals
Following are other examples of various types of Integer
literals:
85 /*decimal*/
0x4b /*hexadecimal*/
30 /*int*/
30u /*unsigned int*/
301 /*long*/
30u1 /*unsigned long*/
C# - Constants and Literals
Floating-point Literals
A floating-point literal has an integer part, a decimal point, a
fractional part, and an exponent part. You can represent
floating point literals either in decimal form or exponential
form.
C# - Constants and Literals
Floating-point Literals
Here are some examples of floating-point literals:
3.14159 /* Legal */
314159E-5F /* Legal */
510E /* Illegal: incomplete exponent */
210f /* Illegal: no decimal or exponent */
.e55 /* Illegal: missing integer or fraction */
C# - Constants and Literals
Floating-point Literals
While representing in decimal form, you must include the
decimal point, the exponent, or both; and representing using
exponential form you must include the integer part, the
fractional part, or both. The signed exponent is introduced
by e or E.
C# - Constants and Literals
Character Constants
Character literals are enclosed in single quotes. For example,
'x' and can be stored in a simple variable of char type. A
character literal can be a plain character (such as 'x'), an
escape sequence (such as 't'), or a universal character (such
as 'u02C0').
C# - Constants and Literals
Character Constants
There are certain characters in C# when they are preceded
by a backslash. They have special meaning and they are
used to represent like newline (n) or tab (t). Here, is a list of
some of such escape sequence codes:
C# - Constants and Literals
Character Constants
Demo
C# - Constants and Literals
String Literals
String literals or constants are enclosed in double quotes ""
or with @"". A string contains characters that are similar to
character literals: plain characters, escape sequences, and
universal characters.
You can break a long line into multiple lines using string
literals and separating the parts using whitespaces.
C# - Constants and Literals
String Literals
Here are some examples of string literals. All the three forms
are identical strings.
"hello, dear"
"hello, 
dear"
"hello, " "d" "ear"
@"hello dear"
C# - Constants and Literals
Defining Constants
Constants are defined using const keyword. Syntax for
defining a constant is:
const <data_type> <constant_name> = value;
Demo
Related Content
•TutorialsPoint
www.tutorialspoint.com
Thank You

More Related Content

PPTX
C# classes objects
Dr.Neeraj Kumar Pandey
 
PPTX
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
PPTX
Array in c#
Prem Kumar Badri
 
PPTX
C++ decision making
Zohaib Ahmed
 
PPT
Methods in C#
Prasanna Kumar SM
 
PPTX
Storage Class in C Progrmming
Kamal Acharya
 
PPTX
Classes and objects in c++
Rokonuzzaman Rony
 
PPTX
Array in Java
Ali shah
 
C# classes objects
Dr.Neeraj Kumar Pandey
 
C# lecture 2: Literals , Variables and Data Types in C#
Dr.Neeraj Kumar Pandey
 
Array in c#
Prem Kumar Badri
 
C++ decision making
Zohaib Ahmed
 
Methods in C#
Prasanna Kumar SM
 
Storage Class in C Progrmming
Kamal Acharya
 
Classes and objects in c++
Rokonuzzaman Rony
 
Array in Java
Ali shah
 

What's hot (20)

PPTX
Union in C programming
Kamal Acharya
 
PPTX
Destructors
DeepikaT13
 
PPT
7.data types in c#
Zeeshan Ahmad
 
PPTX
Conditional and control statement
narmadhakin
 
PPTX
Strings in c++
Neeru Mittal
 
PDF
Java conditional statements
Kuppusamy P
 
PPTX
C functions
University of Potsdam
 
PDF
Arrays in Java
Naz Abdalla
 
PPT
C++ Arrays
أحمد محمد
 
PPT
Introduction to Basic C programming 01
Wingston
 
PPT
Two dimensional array
Rajendran
 
PPTX
File in C language
Manash Kumar Mondal
 
PPSX
python Function
Ronak Rathi
 
PPT
Variables in C Programming
programming9
 
PPTX
C Token’s
Tarun Sharma
 
PPTX
Decision Making & Loops
Akhil Kaushik
 
PPSX
Javascript variables and datatypes
Varun C M
 
DOC
Arrays and Strings
Dr.Subha Krishna
 
PPT
structure and union
student
 
PPTX
arrays and pointers
Samiksha Pun
 
Union in C programming
Kamal Acharya
 
Destructors
DeepikaT13
 
7.data types in c#
Zeeshan Ahmad
 
Conditional and control statement
narmadhakin
 
Strings in c++
Neeru Mittal
 
Java conditional statements
Kuppusamy P
 
Arrays in Java
Naz Abdalla
 
C++ Arrays
أحمد محمد
 
Introduction to Basic C programming 01
Wingston
 
Two dimensional array
Rajendran
 
File in C language
Manash Kumar Mondal
 
python Function
Ronak Rathi
 
Variables in C Programming
programming9
 
C Token’s
Tarun Sharma
 
Decision Making & Loops
Akhil Kaushik
 
Javascript variables and datatypes
Varun C M
 
Arrays and Strings
Dr.Subha Krishna
 
structure and union
student
 
arrays and pointers
Samiksha Pun
 
Ad

Viewers also liked (8)

PPTX
BilgeAdam Nesne Yönelimli Programlama
Sinan Bozkuş
 
PDF
Learn C# Programming - Decision Making & Loops
Eng Teong Cheah
 
PPT
Donanım Sunusu - 5
Bilgisayar Kulübü
 
PPT
C# Variables and Operators
Sunil OS
 
PPT
C# Sunusu - 1
Bilgisayar Kulübü
 
PPT
Variables
Hiba Armouche
 
PPT
Variables
shoffma5
 
PPT
Types of Variables
Ali Mustafa
 
BilgeAdam Nesne Yönelimli Programlama
Sinan Bozkuş
 
Learn C# Programming - Decision Making & Loops
Eng Teong Cheah
 
Donanım Sunusu - 5
Bilgisayar Kulübü
 
C# Variables and Operators
Sunil OS
 
C# Sunusu - 1
Bilgisayar Kulübü
 
Variables
Hiba Armouche
 
Variables
shoffma5
 
Types of Variables
Ali Mustafa
 
Ad

Similar to Learn C# Programming - Variables & Constants (20)

DOCX
C programming tutorial
Mohit Saini
 
PDF
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 
PDF
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
PPTX
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
PPTX
INTRODUCTION TO C++.pptx
MamataAnilgod
 
PPTX
C Program basic concepts using c knoweledge
priankarr1
 
PPTX
C introduction
AswathyBAnil
 
PPT
C the basic concepts
Abhinav Vatsa
 
DOCX
fds unit1.docx
AzhagesvaranTamilsel
 
PPTX
C
PRADEEPA R
 
PPTX
Fundamentals of C Programming Language
RamaBoya2
 
PPTX
Object Oriented Programming with C++
Rokonuzzaman Rony
 
PPT
history of c.ppt
arpanabharani
 
PPTX
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
PPT
U2.ppt
thenmozhip8
 
ODP
CProgrammingTutorial
Muthuselvam RS
 
PPTX
programming for problem solving in C and C++.pptx
BamaSivasubramanianP
 
PPTX
C language ppt
Ğäùråv Júñêjå
 
C programming tutorial
Mohit Saini
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
INTRODUCTION TO C++.pptx
MamataAnilgod
 
C Program basic concepts using c knoweledge
priankarr1
 
C introduction
AswathyBAnil
 
C the basic concepts
Abhinav Vatsa
 
fds unit1.docx
AzhagesvaranTamilsel
 
Fundamentals of C Programming Language
RamaBoya2
 
Object Oriented Programming with C++
Rokonuzzaman Rony
 
history of c.ppt
arpanabharani
 
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 
U2.ppt
thenmozhip8
 
CProgrammingTutorial
Muthuselvam RS
 
programming for problem solving in C and C++.pptx
BamaSivasubramanianP
 
C language ppt
Ğäùråv Júñêjå
 

More from Eng Teong Cheah (20)

PDF
Modern Cross-Platform Apps with .NET MAUI
Eng Teong Cheah
 
PDF
Efficiently Removing Duplicates from a Sorted Array
Eng Teong Cheah
 
PDF
Monitoring Models
Eng Teong Cheah
 
PDF
Responsible Machine Learning
Eng Teong Cheah
 
PDF
Training Optimal Models
Eng Teong Cheah
 
PDF
Deploying Models
Eng Teong Cheah
 
PDF
Machine Learning Workflows
Eng Teong Cheah
 
PDF
Working with Compute
Eng Teong Cheah
 
PDF
Working with Data
Eng Teong Cheah
 
PDF
Experiments & TrainingModels
Eng Teong Cheah
 
PDF
Automated Machine Learning
Eng Teong Cheah
 
PDF
Getting Started with Azure Machine Learning
Eng Teong Cheah
 
PDF
Hacking Containers - Container Storage
Eng Teong Cheah
 
PDF
Hacking Containers - Looking at Cgroups
Eng Teong Cheah
 
PDF
Hacking Containers - Linux Containers
Eng Teong Cheah
 
PDF
Data Security - Storage Security
Eng Teong Cheah
 
PDF
Application Security- App security
Eng Teong Cheah
 
PDF
Application Security - Key Vault
Eng Teong Cheah
 
PDF
Compute Security - Container Security
Eng Teong Cheah
 
PDF
Compute Security - Host Security
Eng Teong Cheah
 
Modern Cross-Platform Apps with .NET MAUI
Eng Teong Cheah
 
Efficiently Removing Duplicates from a Sorted Array
Eng Teong Cheah
 
Monitoring Models
Eng Teong Cheah
 
Responsible Machine Learning
Eng Teong Cheah
 
Training Optimal Models
Eng Teong Cheah
 
Deploying Models
Eng Teong Cheah
 
Machine Learning Workflows
Eng Teong Cheah
 
Working with Compute
Eng Teong Cheah
 
Working with Data
Eng Teong Cheah
 
Experiments & TrainingModels
Eng Teong Cheah
 
Automated Machine Learning
Eng Teong Cheah
 
Getting Started with Azure Machine Learning
Eng Teong Cheah
 
Hacking Containers - Container Storage
Eng Teong Cheah
 
Hacking Containers - Looking at Cgroups
Eng Teong Cheah
 
Hacking Containers - Linux Containers
Eng Teong Cheah
 
Data Security - Storage Security
Eng Teong Cheah
 
Application Security- App security
Eng Teong Cheah
 
Application Security - Key Vault
Eng Teong Cheah
 
Compute Security - Container Security
Eng Teong Cheah
 
Compute Security - Host Security
Eng Teong Cheah
 

Recently uploaded (20)

PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PPTX
Coupa-Overview _Assumptions presentation
annapureddyn
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
PPTX
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
PDF
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PDF
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Advances in Ultra High Voltage (UHV) Transmission and Distribution Systems.pdf
Nabajyoti Banik
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Coupa-Overview _Assumptions presentation
annapureddyn
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
A Day in the Life of Location Data - Turning Where into How.pdf
Precisely
 
What-is-the-World-Wide-Web -- Introduction
tonifi9488
 
Revolutionize Operations with Intelligent IoT Monitoring and Control
Rejig Digital
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
SparkLabs Primer on Artificial Intelligence 2025
SparkLabs Group
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
Chapter 1 Introduction to CV and IP Lecture Note.pdf
Getnet Tigabie Askale -(GM)
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
Cloud-Migration-Best-Practices-A-Practical-Guide-to-AWS-Azure-and-Google-Clou...
Artjoker Software Development Company
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 

Learn C# Programming - Variables & Constants

  • 1. Learn C# Programming Variables and Constants Eng Teong Cheah Microsoft MVP in Visual Studio & Development Technologies
  • 4. C# - Variables A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C# has a specific type, which determines the size and layout of the variable’s memory the range of values that can be stored within that memory and the set of operations that can be applied to the variable.
  • 5. C# - Variables The basic value types provided in C# can be categorized as:
  • 6. C# - Variables C# also allows defining other value types of variable such as enum and reference types of variables such as class, which we will cover in subsequent chapters.
  • 7. C# - Variables Defining Variables Syntax for variable definition in C# is: Here, data_type must be a valid C# data type including char, int, float, double, or any user-defined data type, and variable_list may consist of one or more identifier names separated by commas. <data_type> <variable_list>;
  • 8. C# - Variables Defining Variables Some valid variable definitions are shown here: int i, j, k; char c, ch; float f, salary; double d; You can initialize a variable at the time of definition as: int i = 100;
  • 9. C# - Variables Initializing Variables Variables are initialized (assigned a value) with an equal sign followed by a constant expression. The general form of initialization is: Variables can be initialized in their declaration. The initializer consists of an equal sign followed by a constant expression as: variable_name = value; <data_type> <variable_name> = value;
  • 10. C# - Variables Initializing Variables Some examples are: int d = 3, f = 5; /* initializing d and f. */ byte z = 22; /* initializes z. */ double pi = 3.14159; /*declares an approximation of pi. */ char x = ‘x’;
  • 11. C# - Variables Initializing Variables It is a good programming practice to initialize variables properly, otherwise sometimes program may produce unexpected result.
  • 12. Demo
  • 13. C# - Variables Accepting Values from User The Console class in the System namespace provides function ReadLine() for accepting input from the user and store it into a variable. For example, int num; num = Convert.ToInt32(Console.ReadLine());
  • 14. C# - Variables Accepting Values from User The function Convert.ToInt32() converts the data entered by the user to int data type, because Console.ReadLine() accepts the data in string format.
  • 15. C# - Variables Lvalue and Rvalue Expression in C#: The are two kinds of expressions in C#: - lvalue: An expression that is an lvalue may appear as either the left-hand or right-hand side of an assignment. - rvalue: AN expression that is an rvalue may appear on the right-hand but not left-hand side of an assignment.
  • 16. C# - Variables Lvalue and Rvalue Expression in C#: Variables are lvalues and hence they may appear on the left- hand side of an assignment. Numeric literals are rvalues and hence they may not be assigned and cannot appear on the left-hand side. Following is a valid C# statement: int g =20;
  • 17. C# - Variables Lvalue and Rvalue Expression in C#: But following is not a valid statement and would generate compile-time error: 10 =20;
  • 18. C# - Constants and Literals
  • 19. C# - Constants and Literals The constants refer to fixed values that the program may not alter during its execution. These fixed values also called literals. Constants can be of any of the basic data types like an integer constant, a floating constant, a character constant, or a string literal. There are also enumeration constant as well.
  • 20. C# - Constants and Literals The constants are treated just like regular variables except that their values cannot be modified after their definition.
  • 21. C# - Constants and Literals Integer Literals 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. An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order.
  • 22. C# - Constants and Literals Integer Literals Here are some examples of integer literals: 212 /*Legal*/ 215u /*Legal*/ 0xFeeL /*Legal*/
  • 23. C# - Constants and Literals Integer Literals Following are other examples of various types of Integer literals: 85 /*decimal*/ 0x4b /*hexadecimal*/ 30 /*int*/ 30u /*unsigned int*/ 301 /*long*/ 30u1 /*unsigned long*/
  • 24. C# - Constants and Literals Integer Literals Following are other examples of various types of Integer literals: 85 /*decimal*/ 0x4b /*hexadecimal*/ 30 /*int*/ 30u /*unsigned int*/ 301 /*long*/ 30u1 /*unsigned long*/
  • 25. C# - Constants and Literals Floating-point Literals A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form.
  • 26. C# - Constants and Literals Floating-point Literals Here are some examples of floating-point literals: 3.14159 /* Legal */ 314159E-5F /* Legal */ 510E /* Illegal: incomplete exponent */ 210f /* Illegal: no decimal or exponent */ .e55 /* Illegal: missing integer or fraction */
  • 27. C# - Constants and Literals Floating-point Literals While representing in decimal form, you must include the decimal point, the exponent, or both; and representing using exponential form you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E.
  • 28. C# - Constants and Literals Character Constants Character literals are enclosed in single quotes. For example, 'x' and can be stored in a simple variable of char type. A character literal can be a plain character (such as 'x'), an escape sequence (such as 't'), or a universal character (such as 'u02C0').
  • 29. C# - Constants and Literals Character Constants There are certain characters in C# when they are preceded by a backslash. They have special meaning and they are used to represent like newline (n) or tab (t). Here, is a list of some of such escape sequence codes:
  • 30. C# - Constants and Literals Character Constants
  • 31. Demo
  • 32. C# - Constants and Literals String Literals String literals or constants are enclosed in double quotes "" or with @"". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. You can break a long line into multiple lines using string literals and separating the parts using whitespaces.
  • 33. C# - Constants and Literals String Literals Here are some examples of string literals. All the three forms are identical strings. "hello, dear" "hello, dear" "hello, " "d" "ear" @"hello dear"
  • 34. C# - Constants and Literals Defining Constants Constants are defined using const keyword. Syntax for defining a constant is: const <data_type> <constant_name> = value;
  • 35. Demo