SlideShare a Scribd company logo
1 of 9
C# FOR BEGINNERS
LESSON 2
MICHEAL OGUNDERO
CONTACT :
EMAIL – OGUNDEROAYODEJI@GMAIL.COM
Data Types, Variables and Constants
IN THIS LESSON
• CLASSES
• DATA TYPES
• VARIABLES
• CONSTANTS
CLASSES
• A Class is like an object constructor, or a "blueprint" for creating
objects.
class Table
{
string color = ”Blue";
}
VARIABLES AND DATA TYPES
• A variable is a name given to a storage area that is used to store values
of various data types.
• A variable must be declared with the data type because C# is a
strongly-typed language.
• Each data type includes specific range of values shown in the next slide.
DATA TYPES
Reserved Word .NET Type Type Size (bits) Range (values)
byte Byte Unsigned integer 8 0 to 255
sbyte SByte Signed integer 8 -128 to 127
short Int16 Signed integer 16 -32,768 to 32,767
ushort UInt16 Unsigned integer 16 0 to 65,535
int Int32 Signed integer 32 -2,147,483,648 to
2,147,483,647
uint UInt32 Unsigned integer 32 0 to 4294967295
long Int64 Signed integer 64 -
9,223,372,036,854,775,8
8 to
9,223,372,036,854,775,8
7
ulong UInt64 Unsigned integer 64 0 to
18,446,744,073,709,551,
15
float Single Single-precision floating
point type
32 -3.402823e38 to
3.402823e38
double Double Double-precision
floating point type
64 -1.79769313486232e308
to
1.79769313486232e308
decimal Decimal Precise fractional or
integral type that can
represent decimal
numbers with 29
significant digits
128 (+ or -)1.0 x 10e-28 to
7.9 x 10e28
char Char A single Unicode
character
16 Unicode symbols used
text
bool Boolean Logical Boolean type 8 True or False
object Object Base type of all other
types
string String A sequence of
characters
DateTime DateTime Represents date and
time
0:00:00am 1/1/01 to
11:59:59pm 12/31/9999
VARIABLE DECLARATION
• Variables can be implicitly or explicitly typed
modifier datatype variableName; ///modifier is optional
//variables can be assigned values either separately or on
declaration
variableName = value; ///separate line assignment
modifier dataType variableName = value; //same line
assignment
//implicitly typed variable
var variable2 = value;
CONSTANTS
const is a keyword that indicates a constant. It describes an entity that cannot be
changed at program runtime. Instead, the entity must be fully resolved at compile-time.
Constants promote the integrity of your programs by telling the compiler not to allow
you to change the values during runtime.
C# CODING STANDARDS AND NAMING CONVENTIONS
Object Name Notation Plural Abbreviation
Class name PascalCase No No
Constructor name PascalCase No No
Method name PascalCase Yes No
Method
arguments
camelCase Yes Yes
Local variables camelCase Yes Yes
Constants name PascalCase No No
Field name Underscore Prefix Yes Yes
Properties name PascalCase Yes Yes
Delegate name PascalCase No Yes
Enum type name PascalCase Yes No
• THANK YOU!

More Related Content

What's hot

Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
Tony Apreku
 
C programinng
C programinngC programinng
C programinng
mahi1996
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
vinay arora
 

What's hot (20)

What is identifier c programming
What is identifier c programmingWhat is identifier c programming
What is identifier c programming
 
Variables in C++, data types in c++
Variables in C++, data types in c++Variables in C++, data types in c++
Variables in C++, data types in c++
 
What are variables and keywords in c++
What are variables and keywords in c++What are variables and keywords in c++
What are variables and keywords in c++
 
Structure and Enum in c#
Structure and Enum in c#Structure and Enum in c#
Structure and Enum in c#
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
Object Oriented Principles
Object Oriented PrinciplesObject Oriented Principles
Object Oriented Principles
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
 
Lect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer AbbasLect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer Abbas
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
 
C keywords and identifiers
C keywords and identifiersC keywords and identifiers
C keywords and identifiers
 
Doppl development iteration #2
Doppl development   iteration #2Doppl development   iteration #2
Doppl development iteration #2
 
C language by Dr. Gholkar D. R.
C language by Dr. Gholkar D. R.C language by Dr. Gholkar D. R.
C language by Dr. Gholkar D. R.
 
fundamentals of c
fundamentals of cfundamentals of c
fundamentals of c
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
C programinng
C programinngC programinng
C programinng
 
Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)Lecture02(constants, variable & data types)
Lecture02(constants, variable & data types)
 
3 data-types-in-c
3 data-types-in-c3 data-types-in-c
3 data-types-in-c
 
Chapter1 c programming data types, variables and constants
Chapter1 c programming   data types, variables and constantsChapter1 c programming   data types, variables and constants
Chapter1 c programming data types, variables and constants
 
Module 3 : using value type variables
Module 3 : using value type variablesModule 3 : using value type variables
Module 3 : using value type variables
 

Similar to datatypes_variables_constants

C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
Abhinav Vatsa
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
MAHESHV559910
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
rohassanie
 
Jason yousef ssis expressions - no notes
Jason yousef   ssis expressions - no notesJason yousef   ssis expressions - no notes
Jason yousef ssis expressions - no notes
jasonyousef
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application
Raghu nath
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
YRABHI
 

Similar to datatypes_variables_constants (20)

Data Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# ProgrammingData Types, Variables, and Constants in C# Programming
Data Types, Variables, and Constants in C# Programming
 
C#
C#C#
C#
 
Data Handling
Data HandlingData Handling
Data Handling
 
C the basic concepts
C the basic conceptsC the basic concepts
C the basic concepts
 
Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
434090527-C-Cheat-Sheet. pdf C# program
434090527-C-Cheat-Sheet. pdf  C# program434090527-C-Cheat-Sheet. pdf  C# program
434090527-C-Cheat-Sheet. pdf C# program
 
FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2FP 201 Unit 2 - Part 2
FP 201 Unit 2 - Part 2
 
LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
 
C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#C# lecture 2: Literals , Variables and Data Types in C#
C# lecture 2: Literals , Variables and Data Types in C#
 
Jason yousef ssis expressions - no notes
Jason yousef   ssis expressions - no notesJason yousef   ssis expressions - no notes
Jason yousef ssis expressions - no notes
 
CSE 1201: Structured Programming Language
CSE 1201: Structured Programming LanguageCSE 1201: Structured Programming Language
CSE 1201: Structured Programming Language
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
C
CC
C
 
unit 1 (1).pptx
unit 1 (1).pptxunit 1 (1).pptx
unit 1 (1).pptx
 
C++ data types
C++ data typesC++ data types
C++ data types
 
C# Basics
C# BasicsC# Basics
C# Basics
 
Visual Basics for Application
Visual Basics for Application Visual Basics for Application
Visual Basics for Application
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 

More from Micheal Ogundero

More from Micheal Ogundero (14)

static methods
static methodsstatic methods
static methods
 
csharp repitition structures
csharp repitition structurescsharp repitition structures
csharp repitition structures
 
selection structures
selection structuresselection structures
selection structures
 
escape sequences and substitution markers
escape sequences and substitution markersescape sequences and substitution markers
escape sequences and substitution markers
 
A simple program C# program
A simple program C# programA simple program C# program
A simple program C# program
 
c# operators
c# operatorsc# operators
c# operators
 
2 robot types_classifications
2 robot types_classifications2 robot types_classifications
2 robot types_classifications
 
History of robots
History of robotsHistory of robots
History of robots
 
Dictionary and sets-converted
Dictionary and sets-convertedDictionary and sets-converted
Dictionary and sets-converted
 
Basic Sorting algorithms csharp
Basic Sorting algorithms csharpBasic Sorting algorithms csharp
Basic Sorting algorithms csharp
 
Csharp_List
Csharp_ListCsharp_List
Csharp_List
 
c# Enumerations
c# Enumerationsc# Enumerations
c# Enumerations
 
csharp_Passing_parameters_by_value_and_reference
csharp_Passing_parameters_by_value_and_referencecsharp_Passing_parameters_by_value_and_reference
csharp_Passing_parameters_by_value_and_reference
 
C# Value Data Types and Reference Data Types
C# Value Data Types and Reference Data TypesC# Value Data Types and Reference Data Types
C# Value Data Types and Reference Data Types
 

Recently uploaded

ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
ashishpaul799
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
Morse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptxMorse OER Some Benefits and Challenges.pptx
Morse OER Some Benefits and Challenges.pptx
 
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdfPost Exam Fun(da) Intra UEM General Quiz - Finals.pdf
Post Exam Fun(da) Intra UEM General Quiz - Finals.pdf
 
How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17How to Analyse Profit of a Sales Order in Odoo 17
How to Analyse Profit of a Sales Order in Odoo 17
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 
An Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptxAn Overview of the Odoo 17 Discuss App.pptx
An Overview of the Odoo 17 Discuss App.pptx
 
Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17Features of Video Calls in the Discuss Module in Odoo 17
Features of Video Calls in the Discuss Module in Odoo 17
 
philosophy and it's principles based on the life
philosophy and it's principles based on the lifephilosophy and it's principles based on the life
philosophy and it's principles based on the life
 
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
Exploring Gemini AI and Integration with MuleSoft | MuleSoft Mysore Meetup #45
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
ppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyesppt your views.ppt your views of your college in your eyes
ppt your views.ppt your views of your college in your eyes
 
Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).Dementia (Alzheimer & vasular dementia).
Dementia (Alzheimer & vasular dementia).
 
Championnat de France de Tennis de table/
Championnat de France de Tennis de table/Championnat de France de Tennis de table/
Championnat de France de Tennis de table/
 
....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf....................Muslim-Law notes.pdf
....................Muslim-Law notes.pdf
 
The basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptxThe basics of sentences session 4pptx.pptx
The basics of sentences session 4pptx.pptx
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
Essential Safety precautions during monsoon season
Essential Safety precautions during monsoon seasonEssential Safety precautions during monsoon season
Essential Safety precautions during monsoon season
 
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
Basic Civil Engineering notes on Transportation Engineering, Modes of Transpo...
 

datatypes_variables_constants

  • 1. C# FOR BEGINNERS LESSON 2 MICHEAL OGUNDERO CONTACT : EMAIL – OGUNDEROAYODEJI@GMAIL.COM Data Types, Variables and Constants
  • 2. IN THIS LESSON • CLASSES • DATA TYPES • VARIABLES • CONSTANTS
  • 3. CLASSES • A Class is like an object constructor, or a "blueprint" for creating objects. class Table { string color = ”Blue"; }
  • 4. VARIABLES AND DATA TYPES • A variable is a name given to a storage area that is used to store values of various data types. • A variable must be declared with the data type because C# is a strongly-typed language. • Each data type includes specific range of values shown in the next slide.
  • 5. DATA TYPES Reserved Word .NET Type Type Size (bits) Range (values) byte Byte Unsigned integer 8 0 to 255 sbyte SByte Signed integer 8 -128 to 127 short Int16 Signed integer 16 -32,768 to 32,767 ushort UInt16 Unsigned integer 16 0 to 65,535 int Int32 Signed integer 32 -2,147,483,648 to 2,147,483,647 uint UInt32 Unsigned integer 32 0 to 4294967295 long Int64 Signed integer 64 - 9,223,372,036,854,775,8 8 to 9,223,372,036,854,775,8 7 ulong UInt64 Unsigned integer 64 0 to 18,446,744,073,709,551, 15 float Single Single-precision floating point type 32 -3.402823e38 to 3.402823e38 double Double Double-precision floating point type 64 -1.79769313486232e308 to 1.79769313486232e308 decimal Decimal Precise fractional or integral type that can represent decimal numbers with 29 significant digits 128 (+ or -)1.0 x 10e-28 to 7.9 x 10e28 char Char A single Unicode character 16 Unicode symbols used text bool Boolean Logical Boolean type 8 True or False object Object Base type of all other types string String A sequence of characters DateTime DateTime Represents date and time 0:00:00am 1/1/01 to 11:59:59pm 12/31/9999
  • 6. VARIABLE DECLARATION • Variables can be implicitly or explicitly typed modifier datatype variableName; ///modifier is optional //variables can be assigned values either separately or on declaration variableName = value; ///separate line assignment modifier dataType variableName = value; //same line assignment //implicitly typed variable var variable2 = value;
  • 7. CONSTANTS const is a keyword that indicates a constant. It describes an entity that cannot be changed at program runtime. Instead, the entity must be fully resolved at compile-time. Constants promote the integrity of your programs by telling the compiler not to allow you to change the values during runtime.
  • 8. C# CODING STANDARDS AND NAMING CONVENTIONS Object Name Notation Plural Abbreviation Class name PascalCase No No Constructor name PascalCase No No Method name PascalCase Yes No Method arguments camelCase Yes Yes Local variables camelCase Yes Yes Constants name PascalCase No No Field name Underscore Prefix Yes Yes Properties name PascalCase Yes Yes Delegate name PascalCase No Yes Enum type name PascalCase Yes No