C Sharp
C Sharp
C Sharp
Introduction
What is C#?
• C# is pronounced "C-Sharp".
• It is an object-oriented programming language
created by Microsoft that runs on the .NET
Framework.
• C# has roots from the C family, and the language is
close to other popular languages like C++ and Java.
• The first version was released in year 2002. The
latest version, C# 8, was released in September
2019.
C# is uses
• Mobile applications
• Desktop applications
• Web applications
• Web services
• Web sites
• Games
• VR
• Database applications
Why Use C#?
• All C# variables must
be identified with unique names.
• These unique names are called identifiers.
• Identifiers can be short names (like x and y) or
more descriptive names (age, sum,
totalVolume).
The general rules for constructing names for
variables
• Names can contain letters, digits and the
underscore character (_)
• Names must begin with a letter
• Names should start with a lowercase letter and it
cannot contain whitespace
• Names are case sensitive ("myVar" and "myvar"
are different variables)
• Reserved words (like C# keywords, such
as int or double) cannot be used as names
Common Data Types
Data Type Size Description
int 4 bytes Stores whole numbers from
-2,147,483,648 to
2,147,483,647
long 8 bytes Stores whole numbers from
-9,223,372,036,854,775,80
8 to
9,223,372,036,854,775,807
float 4 bytes Stores fractional numbers.
Sufficient for storing 6 to 7
decimal digits
Common Data Types
double 8 bytes Stores fractional numbers.
Sufficient for storing 15
decimal digits
bool 1 bit Stores true or false values
char 2 bytes Stores a single
character/letter,
surrounded by single
quotes
string 2 bytes per character Sto
Numbers
• Int
• The int data type can store whole numbers
from -2147483648 to 2147483647. In general,
and in our tutorial, the int data type is the
preferred data type when we create variables
with a numeric value.
• Example
int myNum = 100000;
Console.WriteLine(myNum);
Long