Module 3 - Variables, Data Types and Operators
Module 3 - Variables, Data Types and Operators
Variables, Data
Types and Operators
How Programmers Propose?
data_type variable_name;
wherein:
• data_type is any valid data type in C#
• variable_name is any valid identifier in C#
Rules in naming an Identifier
wherein:
• const - is a C# keyword. It tells C# that you are using a constant.
• const_name - is any valid identifier given to the constant.
• value - is the initial value assigned to the constant
C# Data Types
• C# is a “Strongly Typed” language.
• All operations on variables are performed with consideration of
what the variable’s “Type” is.
• There are rules that define what operations are legal to maintain
the integrity of the data you put in a variable.
Fundamental Data Types
C# Data Types
Type Description Range
int 32-bit signed integer -2,147,483,648 to 2,147,483,647
char 16-bit single Unicode character Any valid character, e.g. a,*, \x0058 (hex),
or\u0058 (Unicode)
= Assignment Operator
&& AND
|| OR
! NOT
Operator Precedence
• Operator precedence is a set of rules which defines how an
expression is evaluated.
• Each C# operator has an assigned priority and based on these
priorities, the expression is evaluated.
• The higher the precedence of operator is, the higher it appears in
the table
Table of Precedence
Example No.1
Thanks!
Any questions?
References:
• https://www.tutorialsteacher.com/csharp/csharp-operators
• https://www.tutlane.com/tutorial/csharp/csharp-operators-
precedence-with-examples