SlideShare a Scribd company logo
Software Development  Training Program KAZIM HUSSAIN
First C# Program using System; public class First { public static void Main(string[] args) { Console.WriteLine(“I belong to  Operation Badar”); } }
Parts of a C# Program Class Name   public class First Main method public static void Main(string[] args)   Statements Console.WriteLine(“I belong to  Operation Badar”);
Bits and Bytes Bit is the smallest unit of storage Bit is a digit that can have only two values: ‘0’ or ‘1’ A byte is made up of 8 “bits” 1 Byte 8 Bits 1 0 0 1 1 1 0 1
Memory allocation 10011001 11111001 01110101 10010101 11000001 10111001 01001110 11000101 Main Memory                
Types of Data: “ Datatypes ” Data types are very important in every language for storing and manipulating data Different kinds of data exist All have different features hence difference requirements Nature of data determines its “type”
Datatypes and size in memory Integer Types C# Keyword Size bits/bytes Signed/ Unsigned Type in System Range sbyte 8 bits / 1 byte signed SByte -128 to 127 byte 8 bits / 1 byte unsigned Byte 0 to 255 short 16 bits / 2 bytes signed Int16 -32765 to 32768 ushort 16 bits / 2 bytes unsigned UInt16 0 to 65535 int 32 bits / 4 bytes signed Int32 -2147483648 to 2147483647 uint 32 bits / 4 bytes unsigned UInt32 0 to 4294967195 long 64 bits / 8 bytes signed Int64 -9223373036854775808 to -9223373036854775807 ulong 64 bits / 8 bytes unsigned UInt64 0 to 18446744073709551615
Datatypes and size in memory Floating-Point and Decimal Types C# Keyword Size bits/bytes Significant Figures Type in System Range float 32 bits /  4 bytes 7 Single -3.40282347E38 to 3.40282347E38    1.5 * 10 -45  to  3.4 * 10 38 double 64 bits /  8 bytes 15 Double -1.7976931348623157E308 to 1.7976931348623157E308 5.0 * 10 -324  to  1.7 * 10 308 decimal 96 bits / 12 bytes 28 Decimal -79228162514264337593543950335 to 79228162514264337593543950335 1.0 * 10 -28  to  7.9 * 10 28
Datatypes and size in memory Character Types Boolean Types C# Keyword Size bits/bytes Type in System Value bool 8 bits / 1 byte Boolean true and false C# Keyword Size bits/bytes Type in System Value char 16 bits / 2 bytes Char All Unicode Character
Literals A value of any kind is called a literal Integer literals int count = 2250; / long = 7854214; Floating point literals double d=2.5 E-5.0; / decimal f = 34.34m; Character literals   char c=‘B’; Boolean literals bool b=false; // also ‘true’
Literals NOTE : All the integer types are considered  int  or  long  type by default. All the floating point types are considered  double  by default. So if you want to store  4.4  in  float  datatype you can not write this: -  float f = 4.4; / decimal d = 4.4; Instead you write  float f = 4.4f; decimal d = 4.4m; This way you explicitly tell the compiler to treat 4.4 as float.
Literals If you want to add two byte or short like: byte a = 5; byte b = 5; byte c = a+b; Instead you write byte a = 5; byte b = 5; int c = a+b;
Binary Representation Decimal Numbers Binary numbers Conversion of decimal numbers into binary Conversion of binary numbers into decimal numbers
What is a Variable? `vary` -able   means  change- able The variable is the basic unit of storage. A variable is defined by the combination of a type, variable name and an optional initializer. In c# all variables must be declared before they can be used.    int  a  =  4; Type Name Initial value
Example Some variable declarations examples: - 1. int a = 3; 2. int x,y,z; x = 4; y = 6; z = 3; 3. char c = ‘a’; 4. bool b = true; 5. double d = 44.4, v = 43.3;
What is a Identifier? Identifiers are used to name variables, classes, interfaces, methods, and other elements.  An identifier is a sequence of characters that starts with an underscore ( _ ), or a letter. Subsequent characters may contain these characters plus the digits 0 through 9.
Rules for Identifiers A-Z, a-z, 0-9,_,@ Must not start with digit So followings are valid identifiers: - _minute total Sum4 Hello67_hello @abc_34 _34343
Invalid Identifiers Followings are invalid identifiers: - &total Minute# 4hour @12hello [email_address] $asdfa
Identifiers Both uppercase and lowercase letters can be used in an identifier. Because C# is case sensitive, therefore these are treated as different identifiers: - Total total TOTAL toTal
What is a Keyword? abstract default foreach null sealed uint as delegate goto object short ulong base do if operator sizeof unchecked bool double implicit out stackalloc unsafe break else in override static ushort byte enum int params string using case event interface private struct virtual catch explicit internal protected switch void checked extern is public this while class false lock readonly throw const finally long ref true continue fixed namespace return try decimal float new sbyte typeof
Casting / Conversion Implicit casting When one type of data is assigned to the other type of variable, an automatic type conversion occurs if left hand type is larger than the right hand type. This conversion is sometimes called widening conversion since you are converting small value to large value.
Casting / Conversion byte a = 5; int b = a; long c = b; double d = c; All the above are implicit type casting examples. The right hand side is smaller than the left hand side
Casting / Conversion Explicit casting When you want to assign a larger value to a smaller value, you can not do it without explicitly casting it using the cast operator. This conversion is sometimes called narrowing conversion since you are explicitly making the value narrower to fit into the small size.   The syntax for explicit casting is: target variable = (target) value;
Casting / Conversion NOTE : When you explicitly cast large value to small value some information may be lost. For example, when floating point value is assigned to an integer the fractional part is lost int a = 5; byte b  = a; The second line will cause error. You can cast the second line like this using cast operator. byte b = (byte) a;

More Related Content

What's hot (20)

PPT
Lect 9(pointers) Zaheer Abbas
Information Technology Center
 
PPTX
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 
PPTX
Constants and variables in c programming
Chitrank Dixit
 
PPT
Constants in C Programming
programming9
 
PPTX
Tokens in C++
Mahender Boda
 
PPTX
Concept of c data types
Manisha Keim
 
PPSX
Data type
Frijo Francis
 
PPTX
Constant, variables, data types
Pratik Devmurari
 
PPTX
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
PPTX
Data types
Zahid Hussain
 
PPTX
Data types in C language
kashyap399
 
PPTX
Programming construction tools
sunilchute1
 
PDF
Lecture02(constants, variable & data types)
Dhaka University of Engineering & Technology(DUET)
 
PPTX
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
rahuldaredia21
 
PPT
3 data-types-in-c
teach4uin
 
PPTX
data types in C programming
Harshita Yadav
 
PPTX
Data types
Nokesh Prabhakar
 
PPTX
Data types in C
Tarun Sharma
 
PPT
C++ data types
pratikborsadiya
 
PPT
Data types and Operators
raksharao
 
Lect 9(pointers) Zaheer Abbas
Information Technology Center
 
Datatype in c++ unit 3 -topic 2
MOHIT TOMAR
 
Constants and variables in c programming
Chitrank Dixit
 
Constants in C Programming
programming9
 
Tokens in C++
Mahender Boda
 
Concept of c data types
Manisha Keim
 
Data type
Frijo Francis
 
Constant, variables, data types
Pratik Devmurari
 
A Closer Look at Data Types, Variables and Expressions
Inan Mashrur
 
Data types
Zahid Hussain
 
Data types in C language
kashyap399
 
Programming construction tools
sunilchute1
 
Lecture02(constants, variable & data types)
Dhaka University of Engineering & Technology(DUET)
 
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
rahuldaredia21
 
3 data-types-in-c
teach4uin
 
data types in C programming
Harshita Yadav
 
Data types
Nokesh Prabhakar
 
Data types in C
Tarun Sharma
 
C++ data types
pratikborsadiya
 
Data types and Operators
raksharao
 

Viewers also liked (6)

PPT
C Sharp Jn (2)
guest58c84c
 
PPT
C Sharp Jn
guest58c84c
 
PPT
Microsoft .NET Framework
chandrasekhardesireddi
 
PPSX
Reuters: Pictures of the Year 2016 (Part 2)
maditabalnco
 
PDF
The Six Highest Performing B2B Blog Post Formats
Barry Feldman
 
PDF
The Outcome Economy
Helge Tennø
 
C Sharp Jn (2)
guest58c84c
 
C Sharp Jn
guest58c84c
 
Microsoft .NET Framework
chandrasekhardesireddi
 
Reuters: Pictures of the Year 2016 (Part 2)
maditabalnco
 
The Six Highest Performing B2B Blog Post Formats
Barry Feldman
 
The Outcome Economy
Helge Tennø
 
Ad

Similar to C Sharp Nagina (1) (20)

PPTX
data types in C-Sharp (C#)
Abid Kohistani
 
PPTX
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
PPTX
02. Primitive Data Types and Variables
Intro C# Book
 
PPTX
datatypes_variables_constants
Micheal Ogundero
 
PPT
02 Primitive data types and variables
maznabili
 
PPTX
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
PPTX
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
PDF
C# Data Types and Comments_Lecture2_C#.pdf
Azhar Babil
 
PPTX
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
PPT
C language Unit 2 Slides, UPTU C language
Anurag University Hyderabad
 
PPT
Literals,variables,datatype in C#
Prasanna Kumar SM
 
PPT
Primitive Data Types and Variables Lesson 02
A-Tech and Software Development
 
PPT
Lecture 2
Soran University
 
PDF
C# Language Overview Part I
Doncho Minkov
 
PPTX
Spf Chapter4 Variables
Hock Leng PUAH
 
PDF
C sharp chap2
Mukesh Tekwani
 
PPTX
CSharp Language Overview Part 1
Hossein Zahed
 
PDF
Learn C# Programming - Variables & Constants
Eng Teong Cheah
 
DOCX
Data Type is a basic classification which identifies.docx
theodorelove43763
 
data types in C-Sharp (C#)
Abid Kohistani
 
CS4443 - Modern Programming Language - I Lecture (2)
Dilawar Khan
 
02. Primitive Data Types and Variables
Intro C# Book
 
datatypes_variables_constants
Micheal Ogundero
 
02 Primitive data types and variables
maznabili
 
Lesson 4 Basic Programming Constructs.pptx
John Burca
 
Core C# Programming Constructs, Part 1
Vahid Farahmandian
 
C# Data Types and Comments_Lecture2_C#.pdf
Azhar Babil
 
Data Types, Variables, and Constants in C# Programming
Sherwin Banaag Sapin
 
C language Unit 2 Slides, UPTU C language
Anurag University Hyderabad
 
Literals,variables,datatype in C#
Prasanna Kumar SM
 
Primitive Data Types and Variables Lesson 02
A-Tech and Software Development
 
Lecture 2
Soran University
 
C# Language Overview Part I
Doncho Minkov
 
Spf Chapter4 Variables
Hock Leng PUAH
 
C sharp chap2
Mukesh Tekwani
 
CSharp Language Overview Part 1
Hossein Zahed
 
Learn C# Programming - Variables & Constants
Eng Teong Cheah
 
Data Type is a basic classification which identifies.docx
theodorelove43763
 
Ad

Recently uploaded (20)

PPTX
How to Manage Promotions in Odoo 18 Sales
Celine George
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
PPTX
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PPT
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PPTX
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
PPTX
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
How to Manage Promotions in Odoo 18 Sales
Celine George
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
How to Manage Access Rights & User Types in Odoo 18
Celine George
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
Talk on Critical Theory, Part One, Philosophy of Social Sciences
Soraj Hongladarom
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
1, 2, 3… E MAIS UM CICLO CHEGA AO FIM!.pdf
Colégio Santa Teresinha
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Capitol Doctoral Presentation -July 2025.pptx
CapitolTechU
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPT on the Development of Education in the Victorian England
Beena E S
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
How to Configure Access Rights of Manufacturing Orders in Odoo 18 Manufacturing
Celine George
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
BÀI TẬP BỔ TRỢ THEO LESSON TIẾNG ANH - I-LEARN SMART WORLD 7 - CẢ NĂM - CÓ ĐÁ...
Nguyen Thanh Tu Collection
 
Gall bladder, Small intestine and Large intestine.pptx
rekhapositivity
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 

C Sharp Nagina (1)

  • 1. Software Development Training Program KAZIM HUSSAIN
  • 2. First C# Program using System; public class First { public static void Main(string[] args) { Console.WriteLine(“I belong to Operation Badar”); } }
  • 3. Parts of a C# Program Class Name public class First Main method public static void Main(string[] args) Statements Console.WriteLine(“I belong to Operation Badar”);
  • 4. Bits and Bytes Bit is the smallest unit of storage Bit is a digit that can have only two values: ‘0’ or ‘1’ A byte is made up of 8 “bits” 1 Byte 8 Bits 1 0 0 1 1 1 0 1
  • 5. Memory allocation 10011001 11111001 01110101 10010101 11000001 10111001 01001110 11000101 Main Memory                
  • 6. Types of Data: “ Datatypes ” Data types are very important in every language for storing and manipulating data Different kinds of data exist All have different features hence difference requirements Nature of data determines its “type”
  • 7. Datatypes and size in memory Integer Types C# Keyword Size bits/bytes Signed/ Unsigned Type in System Range sbyte 8 bits / 1 byte signed SByte -128 to 127 byte 8 bits / 1 byte unsigned Byte 0 to 255 short 16 bits / 2 bytes signed Int16 -32765 to 32768 ushort 16 bits / 2 bytes unsigned UInt16 0 to 65535 int 32 bits / 4 bytes signed Int32 -2147483648 to 2147483647 uint 32 bits / 4 bytes unsigned UInt32 0 to 4294967195 long 64 bits / 8 bytes signed Int64 -9223373036854775808 to -9223373036854775807 ulong 64 bits / 8 bytes unsigned UInt64 0 to 18446744073709551615
  • 8. Datatypes and size in memory Floating-Point and Decimal Types C# Keyword Size bits/bytes Significant Figures Type in System Range float 32 bits / 4 bytes 7 Single -3.40282347E38 to 3.40282347E38 1.5 * 10 -45 to 3.4 * 10 38 double 64 bits / 8 bytes 15 Double -1.7976931348623157E308 to 1.7976931348623157E308 5.0 * 10 -324 to 1.7 * 10 308 decimal 96 bits / 12 bytes 28 Decimal -79228162514264337593543950335 to 79228162514264337593543950335 1.0 * 10 -28 to 7.9 * 10 28
  • 9. Datatypes and size in memory Character Types Boolean Types C# Keyword Size bits/bytes Type in System Value bool 8 bits / 1 byte Boolean true and false C# Keyword Size bits/bytes Type in System Value char 16 bits / 2 bytes Char All Unicode Character
  • 10. Literals A value of any kind is called a literal Integer literals int count = 2250; / long = 7854214; Floating point literals double d=2.5 E-5.0; / decimal f = 34.34m; Character literals char c=‘B’; Boolean literals bool b=false; // also ‘true’
  • 11. Literals NOTE : All the integer types are considered int or long type by default. All the floating point types are considered double by default. So if you want to store 4.4 in float datatype you can not write this: - float f = 4.4; / decimal d = 4.4; Instead you write float f = 4.4f; decimal d = 4.4m; This way you explicitly tell the compiler to treat 4.4 as float.
  • 12. Literals If you want to add two byte or short like: byte a = 5; byte b = 5; byte c = a+b; Instead you write byte a = 5; byte b = 5; int c = a+b;
  • 13. Binary Representation Decimal Numbers Binary numbers Conversion of decimal numbers into binary Conversion of binary numbers into decimal numbers
  • 14. What is a Variable? `vary` -able means change- able The variable is the basic unit of storage. A variable is defined by the combination of a type, variable name and an optional initializer. In c# all variables must be declared before they can be used. int a = 4; Type Name Initial value
  • 15. Example Some variable declarations examples: - 1. int a = 3; 2. int x,y,z; x = 4; y = 6; z = 3; 3. char c = ‘a’; 4. bool b = true; 5. double d = 44.4, v = 43.3;
  • 16. What is a Identifier? Identifiers are used to name variables, classes, interfaces, methods, and other elements. An identifier is a sequence of characters that starts with an underscore ( _ ), or a letter. Subsequent characters may contain these characters plus the digits 0 through 9.
  • 17. Rules for Identifiers A-Z, a-z, 0-9,_,@ Must not start with digit So followings are valid identifiers: - _minute total Sum4 Hello67_hello @abc_34 _34343
  • 18. Invalid Identifiers Followings are invalid identifiers: - &total Minute# 4hour @12hello [email_address] $asdfa
  • 19. Identifiers Both uppercase and lowercase letters can be used in an identifier. Because C# is case sensitive, therefore these are treated as different identifiers: - Total total TOTAL toTal
  • 20. What is a Keyword? abstract default foreach null sealed uint as delegate goto object short ulong base do if operator sizeof unchecked bool double implicit out stackalloc unsafe break else in override static ushort byte enum int params string using case event interface private struct virtual catch explicit internal protected switch void checked extern is public this while class false lock readonly throw const finally long ref true continue fixed namespace return try decimal float new sbyte typeof
  • 21. Casting / Conversion Implicit casting When one type of data is assigned to the other type of variable, an automatic type conversion occurs if left hand type is larger than the right hand type. This conversion is sometimes called widening conversion since you are converting small value to large value.
  • 22. Casting / Conversion byte a = 5; int b = a; long c = b; double d = c; All the above are implicit type casting examples. The right hand side is smaller than the left hand side
  • 23. Casting / Conversion Explicit casting When you want to assign a larger value to a smaller value, you can not do it without explicitly casting it using the cast operator. This conversion is sometimes called narrowing conversion since you are explicitly making the value narrower to fit into the small size. The syntax for explicit casting is: target variable = (target) value;
  • 24. Casting / Conversion NOTE : When you explicitly cast large value to small value some information may be lost. For example, when floating point value is assigned to an integer the fractional part is lost int a = 5; byte b = a; The second line will cause error. You can cast the second line like this using cast operator. byte b = (byte) a;