SlideShare a Scribd company logo
Chapter 4
Literals, variables and Data Types
The smallest, non-reducible, textual elements in a program are referred to as Tokens. A C# program is a
collection of tokens, comments and white spaces. C# include the following five types of tokens:
Keywords, Identifiers, Literals, Operators, Punctuators
Keywords are an essential part of a language definition. They implement specific features of the
language. They are reserved, and cannot be used as identifiers except when they are prefaced by the @
character.
Identifiers are programmer –designed tokens. They are used for naming classes, methods, variables,
labels, namespace, interfaces, etc. C# identifiers enforce the following rules: They can have
alphabets, digits and underscore character. They must not begin with a digit. Upper case and lower case
letters are distinct.
Literals are the way in which the values that are stored in variables are represented.
Operators are symbols used in expressions to describe operations involving one or more operands.
Punctuators are symbols used for grouping and separating code. Punctuators in C# include:
Parentheses, Braces, Brackets, Semicolon, Colon, Comma, Period.
C# implements several types of statements:
Empty Statements, Labeled Statement, Declaration statements, Expression statement, Selection
statement, Interaction statements, Jump statements, try statements, checked statements, unchecked
statements, lock statements, using statements.
Scope of Variables
The scope of variables is the region of code within which the variable can be accessed.
C# variables are categorized into
- Static variables
- Instance Variables
- Array elements
- Value Parameters
- Reference Parameters
- Output Parameters
- Local variables
the scope of variables are
- m is a static variable
- n is an instance variable
- a is a value parameter
- b is an reference parameter
- c is an output parameter
- arr is an array element
-d is a local variable.
Static and instance variables are declared at the class level and are known as fields and ends when the
main method terminates. The reference and output parameters do not create new storage locations,
they represent the same storage locations as the variables that are passed as arguments.
The scope of a local variables starts immediately after its identifier in the declaration and extends up to
the end of the block containing the declaration. C# makes a fundamental distinction between the field
variables declared at the class level and the local variables declared within methods.
Boxing and Unboxing
Boxing means the conversion of a value type on the stack to a object type on the heap, conversely, the
conversion from an object type back to a value type is known as unboxing.
Boxing – Any type, value or reference can be assigned to an object without an explicit conversion.
When the compiler finds a value type where it needs a reference type, it creates an object ‘Box’ into
which it places the value of the value type.
Unboxing – Unboxing is the process of converting the object type back to the value type. A variable
that has previously been boxed can only be unboxed. While unboxing the object could be cast to any
type.
class Sample
{
static int m; int n;
void Test (int a, ref int b, out int
c, int [] arr)
{ int d = 100; …………
}
}
Method Overloading
- C# allows us to create more than one method with the same name, but with the different parameter
lists and different definitions. This is called method overloading. - Method overloading is used
when methods are required to perform similar tasks but using different input parameters.
- Overloaded methods must differ in number and/or type of parameters they take. This enables the
compiler to decide which one of the definitions to execute depending on the type and number of
arguments in the method call. - using the concept of method overloading, a family of methods
with one name but different arguments lists can be designed.
The method selection involves the following steps: 1) The compiler tries to find an exact match in
which the types of actual parameters are same and uses that method. 2) if the exact match
is not found, then the compiler tries to use the implicit conversions to the actual arguments and then
uses the method whose match is unique. If the conversion creates multiple matches, then the compiler
will generate an error message.

More Related Content

What's hot

Learn C# Programming - Operators
Learn C# Programming - OperatorsLearn C# Programming - Operators
Learn C# Programming - Operators
Eng Teong Cheah
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
K Durga Prasad
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III Term
Andrew Raj
 
Ch6
Ch6Ch6
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
sophoeutsen2
 
Programming in C- Introduction
Programming in C- IntroductionProgramming in C- Introduction
Programming in C- Introduction
savitamhaske
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
Rai University
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
birbal
 
Assignment5
Assignment5Assignment5
Assignment5
Sunita Milind Dol
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
Anil Dutt
 
C++
C++C++
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
KRUNAL RAVAL
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
Shobi P P
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
Ameer Khan
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
Rakesh Roshan
 
Pc module1
Pc module1Pc module1
Pc module1
SANTOSH RATH
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
Abed Bukhari
 
C material
C materialC material
C material
tarique472
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
Tony Apreku
 
C tokens
C tokensC tokens
C tokens
Manu1325
 

What's hot (20)

Learn C# Programming - Operators
Learn C# Programming - OperatorsLearn C# Programming - Operators
Learn C# Programming - Operators
 
Getting started with c++
Getting started with c++Getting started with c++
Getting started with c++
 
C programming | Class 8 | III Term
C programming  | Class 8  | III TermC programming  | Class 8  | III Term
C programming | Class 8 | III Term
 
Ch6
Ch6Ch6
Ch6
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
Programming in C- Introduction
Programming in C- IntroductionProgramming in C- Introduction
Programming in C- Introduction
 
datatypes and variables in c language
 datatypes and variables in c language datatypes and variables in c language
datatypes and variables in c language
 
Javascript by Yahoo
Javascript by YahooJavascript by Yahoo
Javascript by Yahoo
 
Assignment5
Assignment5Assignment5
Assignment5
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
C++
C++C++
C++
 
FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
 
Complete Tokens in c/c++
Complete Tokens in c/c++Complete Tokens in c/c++
Complete Tokens in c/c++
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
 
C language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C languageC language Unit 2 Slides, UPTU C language
C language Unit 2 Slides, UPTU C language
 
Pc module1
Pc module1Pc module1
Pc module1
 
Csharp4 basics
Csharp4 basicsCsharp4 basics
Csharp4 basics
 
C material
C materialC material
C material
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
C tokens
C tokensC tokens
C tokens
 

Viewers also liked

Is case study
Is   case studyIs   case study
Is case study
Shehrevar Davierwala
 
C# programs
C# programsC# programs
C# chap 2
C# chap 2C# chap 2
Wireless lan
Wireless lanWireless lan
Wireless lan
Shehrevar Davierwala
 
What is this
What is thisWhat is this
What is this
Mohd Azhar
 
numbers system
numbers systemnumbers system
numbers system
Shehrevar Davierwala
 
Jstreams
JstreamsJstreams
Tech talk php_cms
Tech talk php_cmsTech talk php_cms
Tech talk php_cms
Shehrevar Davierwala
 
Tech talk webtech
Tech talk webtechTech talk webtech
Tech talk webtech
Shehrevar Davierwala
 

Viewers also liked (9)

Is case study
Is   case studyIs   case study
Is case study
 
C# programs
C# programsC# programs
C# programs
 
C# chap 2
C# chap 2C# chap 2
C# chap 2
 
Wireless lan
Wireless lanWireless lan
Wireless lan
 
What is this
What is thisWhat is this
What is this
 
numbers system
numbers systemnumbers system
numbers system
 
Jstreams
JstreamsJstreams
Jstreams
 
Tech talk php_cms
Tech talk php_cmsTech talk php_cms
Tech talk php_cms
 
Tech talk webtech
Tech talk webtechTech talk webtech
Tech talk webtech
 

Similar to C# chap 4

Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
sandeshjadhav28
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
InfinityWorld3
 
LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
Tabassum Ghulame Mustafa
 
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
Sherwin Banaag Sapin
 
Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++
DevangiParekh1
 
C language 3
C language 3C language 3
C language 3
Arafat Bin Reza
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
Raghuveer Guthikonda
 
Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
megersaoljira
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
Vasuki Ramasamy
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
ArshiniGubbala3
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
MMRF2
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
jatin batra
 
CSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdfCSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdf
ssusera0bb35
 
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
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
arpanabharani
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
talenttransform
 
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#
Dr.Neeraj Kumar Pandey
 
c# at f#
c# at f#c# at f#
c# at f#
Harry Balois
 
C# AND F#
C# AND F#C# AND F#
C# AND F#
Harry Balois
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
jatin batra
 

Similar to C# chap 4 (20)

Dot net programming concept
Dot net  programming conceptDot net  programming concept
Dot net programming concept
 
Notes(1).pptx
Notes(1).pptxNotes(1).pptx
Notes(1).pptx
 
LEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMTLEARN C# PROGRAMMING WITH GMT
LEARN C# PROGRAMMING WITH GMT
 
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
 
Basic Structure Of C++
Basic Structure Of C++Basic Structure Of C++
Basic Structure Of C++
 
C language 3
C language 3C language 3
C language 3
 
Introduction to C#
Introduction to C#Introduction to C#
Introduction to C#
 
Chapter 2 c#
Chapter 2 c#Chapter 2 c#
Chapter 2 c#
 
Unit 1 question and answer
Unit 1 question and answerUnit 1 question and answer
Unit 1 question and answer
 
PSPC--UNIT-2.pdf
PSPC--UNIT-2.pdfPSPC--UNIT-2.pdf
PSPC--UNIT-2.pdf
 
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdfL2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
L2 C# Programming Comments, Keywords, Identifiers, Variables.pdf
 
C presentation! BATRA COMPUTER CENTRE
C presentation! BATRA  COMPUTER  CENTRE C presentation! BATRA  COMPUTER  CENTRE
C presentation! BATRA COMPUTER CENTRE
 
CSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdfCSharpCheatSheetV1.pdf
CSharpCheatSheetV1.pdf
 
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
 
history of c.ppt
history of c.ppthistory of c.ppt
history of c.ppt
 
Evolution of c# - by K.Jegan
Evolution of c# - by K.JeganEvolution of c# - by K.Jegan
Evolution of c# - by K.Jegan
 
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#
 
c# at f#
c# at f#c# at f#
c# at f#
 
C# AND F#
C# AND F#C# AND F#
C# AND F#
 
C programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer CentreC programming Training in Ambala ! Batra Computer Centre
C programming Training in Ambala ! Batra Computer Centre
 

More from Shehrevar Davierwala

Introduction_Swift
Introduction_SwiftIntroduction_Swift
Introduction_Swift
Shehrevar Davierwala
 
PsudoCode.pptx
PsudoCode.pptxPsudoCode.pptx
PsudoCode.pptx
Shehrevar Davierwala
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
Shehrevar Davierwala
 
Java Script (Module 1).pptx
Java Script (Module 1).pptxJava Script (Module 1).pptx
Java Script (Module 1).pptx
Shehrevar Davierwala
 
Website in Clicks Day 2
Website in Clicks Day 2Website in Clicks Day 2
Website in Clicks Day 2
Shehrevar Davierwala
 
Develop Website in Clicks
Develop Website in ClicksDevelop Website in Clicks
Develop Website in Clicks
Shehrevar Davierwala
 
Build Virtual Assistant Using AI
Build Virtual Assistant Using AI Build Virtual Assistant Using AI
Build Virtual Assistant Using AI
Shehrevar Davierwala
 
Build brand reputation using facebook
Build brand reputation using facebookBuild brand reputation using facebook
Build brand reputation using facebook
Shehrevar Davierwala
 
Digital Marketing Session 2
Digital Marketing Session 2Digital Marketing Session 2
Digital Marketing Session 2
Shehrevar Davierwala
 
Learn Digital Marketing : 0 to Hero Day 1
Learn Digital Marketing :  0 to Hero Day 1 Learn Digital Marketing :  0 to Hero Day 1
Learn Digital Marketing : 0 to Hero Day 1
Shehrevar Davierwala
 
Standard template
Standard templateStandard template
Standard template
Shehrevar Davierwala
 
Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective  Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective
Shehrevar Davierwala
 
Developing stunning website in clicks - 2
Developing stunning website in clicks - 2Developing stunning website in clicks - 2
Developing stunning website in clicks - 2
Shehrevar Davierwala
 
Developing stunning website in clicks
Developing stunning website in clicksDeveloping stunning website in clicks
Developing stunning website in clicks
Shehrevar Davierwala
 
Google forms for data analysis
Google forms for data analysisGoogle forms for data analysis
Google forms for data analysis
Shehrevar Davierwala
 
Webdesign session1
Webdesign session1Webdesign session1
Webdesign session1
Shehrevar Davierwala
 
Ph pbasics
Ph pbasicsPh pbasics
Php mysql
Php mysqlPhp mysql
Java operators
Java operatorsJava operators
Java operators
Shehrevar Davierwala
 
Basic
BasicBasic

More from Shehrevar Davierwala (20)

Introduction_Swift
Introduction_SwiftIntroduction_Swift
Introduction_Swift
 
PsudoCode.pptx
PsudoCode.pptxPsudoCode.pptx
PsudoCode.pptx
 
Number System.pptx
Number System.pptxNumber System.pptx
Number System.pptx
 
Java Script (Module 1).pptx
Java Script (Module 1).pptxJava Script (Module 1).pptx
Java Script (Module 1).pptx
 
Website in Clicks Day 2
Website in Clicks Day 2Website in Clicks Day 2
Website in Clicks Day 2
 
Develop Website in Clicks
Develop Website in ClicksDevelop Website in Clicks
Develop Website in Clicks
 
Build Virtual Assistant Using AI
Build Virtual Assistant Using AI Build Virtual Assistant Using AI
Build Virtual Assistant Using AI
 
Build brand reputation using facebook
Build brand reputation using facebookBuild brand reputation using facebook
Build brand reputation using facebook
 
Digital Marketing Session 2
Digital Marketing Session 2Digital Marketing Session 2
Digital Marketing Session 2
 
Learn Digital Marketing : 0 to Hero Day 1
Learn Digital Marketing :  0 to Hero Day 1 Learn Digital Marketing :  0 to Hero Day 1
Learn Digital Marketing : 0 to Hero Day 1
 
Standard template
Standard templateStandard template
Standard template
 
Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective  Digital Marketing for Sustainable Business - Afghan Perspective
Digital Marketing for Sustainable Business - Afghan Perspective
 
Developing stunning website in clicks - 2
Developing stunning website in clicks - 2Developing stunning website in clicks - 2
Developing stunning website in clicks - 2
 
Developing stunning website in clicks
Developing stunning website in clicksDeveloping stunning website in clicks
Developing stunning website in clicks
 
Google forms for data analysis
Google forms for data analysisGoogle forms for data analysis
Google forms for data analysis
 
Webdesign session1
Webdesign session1Webdesign session1
Webdesign session1
 
Ph pbasics
Ph pbasicsPh pbasics
Ph pbasics
 
Php mysql
Php mysqlPhp mysql
Php mysql
 
Java operators
Java operatorsJava operators
Java operators
 
Basic
BasicBasic
Basic
 

Recently uploaded

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
名前 です男
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
DianaGray10
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
Matthew Sinclair
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
Zilliz
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
Neo4j
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
panagenda
 

Recently uploaded (20)

Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
みなさんこんにちはこれ何文字まで入るの?40文字以下不可とか本当に意味わからないけどこれ限界文字数書いてないからマジでやばい文字数いけるんじゃないの?えこ...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1Communications Mining Series - Zero to Hero - Session 1
Communications Mining Series - Zero to Hero - Session 1
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
20240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 202420240605 QFM017 Machine Intelligence Reading List May 2024
20240605 QFM017 Machine Intelligence Reading List May 2024
 
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Programming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup SlidesProgramming Foundation Models with DSPy - Meetup Slides
Programming Foundation Models with DSPy - Meetup Slides
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...
 
HCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAUHCL Notes and Domino License Cost Reduction in the World of DLAU
HCL Notes and Domino License Cost Reduction in the World of DLAU
 

C# chap 4

  • 1. Chapter 4 Literals, variables and Data Types The smallest, non-reducible, textual elements in a program are referred to as Tokens. A C# program is a collection of tokens, comments and white spaces. C# include the following five types of tokens: Keywords, Identifiers, Literals, Operators, Punctuators Keywords are an essential part of a language definition. They implement specific features of the language. They are reserved, and cannot be used as identifiers except when they are prefaced by the @ character. Identifiers are programmer –designed tokens. They are used for naming classes, methods, variables, labels, namespace, interfaces, etc. C# identifiers enforce the following rules: They can have alphabets, digits and underscore character. They must not begin with a digit. Upper case and lower case letters are distinct. Literals are the way in which the values that are stored in variables are represented. Operators are symbols used in expressions to describe operations involving one or more operands. Punctuators are symbols used for grouping and separating code. Punctuators in C# include: Parentheses, Braces, Brackets, Semicolon, Colon, Comma, Period. C# implements several types of statements: Empty Statements, Labeled Statement, Declaration statements, Expression statement, Selection statement, Interaction statements, Jump statements, try statements, checked statements, unchecked statements, lock statements, using statements. Scope of Variables The scope of variables is the region of code within which the variable can be accessed. C# variables are categorized into - Static variables - Instance Variables - Array elements - Value Parameters - Reference Parameters - Output Parameters - Local variables
  • 2. the scope of variables are - m is a static variable - n is an instance variable - a is a value parameter - b is an reference parameter - c is an output parameter - arr is an array element -d is a local variable. Static and instance variables are declared at the class level and are known as fields and ends when the main method terminates. The reference and output parameters do not create new storage locations, they represent the same storage locations as the variables that are passed as arguments. The scope of a local variables starts immediately after its identifier in the declaration and extends up to the end of the block containing the declaration. C# makes a fundamental distinction between the field variables declared at the class level and the local variables declared within methods. Boxing and Unboxing Boxing means the conversion of a value type on the stack to a object type on the heap, conversely, the conversion from an object type back to a value type is known as unboxing. Boxing – Any type, value or reference can be assigned to an object without an explicit conversion. When the compiler finds a value type where it needs a reference type, it creates an object ‘Box’ into which it places the value of the value type. Unboxing – Unboxing is the process of converting the object type back to the value type. A variable that has previously been boxed can only be unboxed. While unboxing the object could be cast to any type. class Sample { static int m; int n; void Test (int a, ref int b, out int c, int [] arr) { int d = 100; ………… } }
  • 3. Method Overloading - C# allows us to create more than one method with the same name, but with the different parameter lists and different definitions. This is called method overloading. - Method overloading is used when methods are required to perform similar tasks but using different input parameters. - Overloaded methods must differ in number and/or type of parameters they take. This enables the compiler to decide which one of the definitions to execute depending on the type and number of arguments in the method call. - using the concept of method overloading, a family of methods with one name but different arguments lists can be designed. The method selection involves the following steps: 1) The compiler tries to find an exact match in which the types of actual parameters are same and uses that method. 2) if the exact match is not found, then the compiler tries to use the implicit conversions to the actual arguments and then uses the method whose match is unique. If the conversion creates multiple matches, then the compiler will generate an error message.