SlideShare a Scribd company logo
1 of 16
Presentation Topic:
Array & Exception Handling in C#
Name :Md. Sihab Uddin
Batch : 6th
Semester : 8th
ID. : 00616306005
Pundra University of Science & Technology
Computer Science & Engineering
7/2/2020 1Array & Exception Handling in C#
Arrays
• An array is a group of like-typed variables that are referred to
by a common name.
• The data types of the elements may be any valid data type like
char, int, float, etc.
• The elements are stored in a contiguous location.
• Length of the array specifies the number of elements present in
the array.
• The variables in the array are ordered and each has an index
beginning from 0.
7/2/2020 Array & Exception Handling in C# 2
Arrays(cont…)
• The following figure shows how array stores values
sequentially :
7/2/2020 Array & Exception Handling in C# 3
Array Declaration
• Syntax :
< Data Type > [ ] < Array_Name >
• Here:
< Data Type > : It define the element type of the array.
[ ] : It define the size of the array.
< Array_Name > : It is the Name of array.
• Example :
int[] x;
string[] s;
• Note :
Only Declaration of an array doesn’t allocate memory to the
array. For that array must be initialized.
7/2/2020 Array & Exception Handling in C# 4
Array Initialization
• Syntax :
type [ ] < Name_Array > = new < data_type > [size];
• Here:
 type specifies the type of data being allocated,
 size specifies the number of elements in the array,
 Name_Array is the name of array variable.
 new will allocate memory to an array according to its size.
7/2/2020 Array & Exception Handling in C# 5
Array Initialization(cont…)
 To Show Different ways for the Array Declaration and
Initialization:
• Example 1 :
– defining array with size 5. But not assigns values
– int[] intArray1 = new int[5];
• Example 2 :
– defining array with size 5 and assigning values at the same time
– int[] intArray2 = new int[5]{1, 2, 3, 4, 5};
• Example 3 :
– defining array with 5 elements which indicates the size of an array
– int[] intArray3 = {1, 2, 3, 4, 5};
7/2/2020 Array & Exception Handling in C# 6
Array(Example)
7/2/2020 Array & Exception Handling in C# 7
Array(Example)
7/2/2020 Array & Exception Handling in C# 8
One Dimensional Array
• In this array contains only one row for storing the values. All
values of this array are stored contiguously starting from 0 to
the array size. For example, declaring a single-dimensional
array of 5 integers :
• Syntax :
type [ ] < Array_Name> = new < data_type > [size];
• Example:
int[ ] array_int = new int[5];
7/2/2020 Array & Exception Handling in C# 9
Multidimensional Arrays
• The multi-dimensional array contains more than one row to
store the values.
• It is also known as a Rectangular Array in C# because it’s
each row length is same.
• It can be a 2D-array or 3D-array or more.
• To storing and accessing the values of the array, one required
the nested loop.
7/2/2020 Array & Exception Handling in C# 10
Multidimensional Arrays(cont…)
• The multi-dimensional array declaration, initialization and
accessing is as follows :
• Syntax :
 Creates a two-dimensional array of four rows and two
columns.
int[ , ] intarray = new int[4, 2];
 Creates an array of three dimensions, 4, 2, and 3
int[ , , ] intarray1 = new int[4, 2, 3];
7/2/2020 Array & Exception Handling in C# 11
Exception
• Exceptions are unusual error conditions that occur during
execution of a program or an application.
• An exception is an unwanted or unexpected event, which
occurs during the execution of a program i.e at runtime, that
disrupts the normal flow of the program’s instructions.
7/2/2020 Array & Exception Handling in C# 12
Exception Handling
C# exception handling is built upon four keywords:
• try − A try block identifies a block of code for which particular
exceptions is activated. It is followed by one or more catch
blocks.
• catch − A program catches an exception with an exception
handler at the place in a program where you want to handle the
problem.
• finally − The finally block is used to execute a given set of
statements.
• throw − A program throws an exception when a problem shows
up. This is done using a throw keyword.
7/2/2020 Array & Exception Handling in C# 13
Exception Handling(cont…)
• Syntax:
try {
// statements causing exception
}
catch( ExceptionName e1 ) {
// error handling code
}
catch( ExceptionName eN ) {
// error handling code
}
finally {
// statements to be executed
}
7/2/2020 Array & Exception Handling in C# 14
Exception Handling(Example)
7/2/2020 Array & Exception Handling in C# 15
Thank You
7/2/2020 16Array & Exception Handling in C#

More Related Content

What's hot (18)

FUNDAMENTAL OF C
FUNDAMENTAL OF CFUNDAMENTAL OF C
FUNDAMENTAL OF C
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Advanced VB: Review of the basics
Advanced VB: Review of the basicsAdvanced VB: Review of the basics
Advanced VB: Review of the basics
 
Methods in C#
Methods in C#Methods in C#
Methods in C#
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
Constants and variables in c programming
Constants and variables in c programmingConstants and variables in c programming
Constants and variables in c programming
 
Python l3
Python l3Python l3
Python l3
 
Basic of c &c++
Basic of c &c++Basic of c &c++
Basic of c &c++
 
Ppt lesson 08
Ppt lesson 08Ppt lesson 08
Ppt lesson 08
 
C# operators
C# operatorsC# operators
C# operators
 
Arrays
ArraysArrays
Arrays
 
data structures and algorithms Unit 1
data structures and algorithms Unit 1data structures and algorithms Unit 1
data structures and algorithms Unit 1
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
 
Ppt lesson 07
Ppt lesson 07Ppt lesson 07
Ppt lesson 07
 
Frequently asked questions in c
Frequently asked questions in cFrequently asked questions in c
Frequently asked questions in c
 
Frequently asked questions in c
Frequently asked questions in cFrequently asked questions in c
Frequently asked questions in c
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 

Similar to Array & Exception Handling in C# (CSharp)

Similar to Array & Exception Handling in C# (CSharp) (20)

Visual Programing basic lectures 7.pptx
Visual Programing basic lectures  7.pptxVisual Programing basic lectures  7.pptx
Visual Programing basic lectures 7.pptx
 
Arrays In General
Arrays In GeneralArrays In General
Arrays In General
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Arrays
ArraysArrays
Arrays
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Arrays
ArraysArrays
Arrays
 
Array and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdfArray and its types and it's implemented programming Final.pdf
Array and its types and it's implemented programming Final.pdf
 
Ch8 Arrays
Ch8 ArraysCh8 Arrays
Ch8 Arrays
 
Java part 2
Java part  2Java part  2
Java part 2
 
7array in c#
7array in c#7array in c#
7array in c#
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Functions, Strings ,Storage classes in C
 Functions, Strings ,Storage classes in C Functions, Strings ,Storage classes in C
Functions, Strings ,Storage classes in C
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 
Array
ArrayArray
Array
 
Break and continue in C
Break and continue in C Break and continue in C
Break and continue in C
 
Ch08
Ch08Ch08
Ch08
 
Chap 6 c++
Chap 6 c++Chap 6 c++
Chap 6 c++
 

Recently uploaded

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 

Recently uploaded (20)

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 

Array & Exception Handling in C# (CSharp)

  • 1. Presentation Topic: Array & Exception Handling in C# Name :Md. Sihab Uddin Batch : 6th Semester : 8th ID. : 00616306005 Pundra University of Science & Technology Computer Science & Engineering 7/2/2020 1Array & Exception Handling in C#
  • 2. Arrays • An array is a group of like-typed variables that are referred to by a common name. • The data types of the elements may be any valid data type like char, int, float, etc. • The elements are stored in a contiguous location. • Length of the array specifies the number of elements present in the array. • The variables in the array are ordered and each has an index beginning from 0. 7/2/2020 Array & Exception Handling in C# 2
  • 3. Arrays(cont…) • The following figure shows how array stores values sequentially : 7/2/2020 Array & Exception Handling in C# 3
  • 4. Array Declaration • Syntax : < Data Type > [ ] < Array_Name > • Here: < Data Type > : It define the element type of the array. [ ] : It define the size of the array. < Array_Name > : It is the Name of array. • Example : int[] x; string[] s; • Note : Only Declaration of an array doesn’t allocate memory to the array. For that array must be initialized. 7/2/2020 Array & Exception Handling in C# 4
  • 5. Array Initialization • Syntax : type [ ] < Name_Array > = new < data_type > [size]; • Here:  type specifies the type of data being allocated,  size specifies the number of elements in the array,  Name_Array is the name of array variable.  new will allocate memory to an array according to its size. 7/2/2020 Array & Exception Handling in C# 5
  • 6. Array Initialization(cont…)  To Show Different ways for the Array Declaration and Initialization: • Example 1 : – defining array with size 5. But not assigns values – int[] intArray1 = new int[5]; • Example 2 : – defining array with size 5 and assigning values at the same time – int[] intArray2 = new int[5]{1, 2, 3, 4, 5}; • Example 3 : – defining array with 5 elements which indicates the size of an array – int[] intArray3 = {1, 2, 3, 4, 5}; 7/2/2020 Array & Exception Handling in C# 6
  • 7. Array(Example) 7/2/2020 Array & Exception Handling in C# 7
  • 8. Array(Example) 7/2/2020 Array & Exception Handling in C# 8
  • 9. One Dimensional Array • In this array contains only one row for storing the values. All values of this array are stored contiguously starting from 0 to the array size. For example, declaring a single-dimensional array of 5 integers : • Syntax : type [ ] < Array_Name> = new < data_type > [size]; • Example: int[ ] array_int = new int[5]; 7/2/2020 Array & Exception Handling in C# 9
  • 10. Multidimensional Arrays • The multi-dimensional array contains more than one row to store the values. • It is also known as a Rectangular Array in C# because it’s each row length is same. • It can be a 2D-array or 3D-array or more. • To storing and accessing the values of the array, one required the nested loop. 7/2/2020 Array & Exception Handling in C# 10
  • 11. Multidimensional Arrays(cont…) • The multi-dimensional array declaration, initialization and accessing is as follows : • Syntax :  Creates a two-dimensional array of four rows and two columns. int[ , ] intarray = new int[4, 2];  Creates an array of three dimensions, 4, 2, and 3 int[ , , ] intarray1 = new int[4, 2, 3]; 7/2/2020 Array & Exception Handling in C# 11
  • 12. Exception • Exceptions are unusual error conditions that occur during execution of a program or an application. • An exception is an unwanted or unexpected event, which occurs during the execution of a program i.e at runtime, that disrupts the normal flow of the program’s instructions. 7/2/2020 Array & Exception Handling in C# 12
  • 13. Exception Handling C# exception handling is built upon four keywords: • try − A try block identifies a block of code for which particular exceptions is activated. It is followed by one or more catch blocks. • catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. • finally − The finally block is used to execute a given set of statements. • throw − A program throws an exception when a problem shows up. This is done using a throw keyword. 7/2/2020 Array & Exception Handling in C# 13
  • 14. Exception Handling(cont…) • Syntax: try { // statements causing exception } catch( ExceptionName e1 ) { // error handling code } catch( ExceptionName eN ) { // error handling code } finally { // statements to be executed } 7/2/2020 Array & Exception Handling in C# 14
  • 15. Exception Handling(Example) 7/2/2020 Array & Exception Handling in C# 15
  • 16. Thank You 7/2/2020 16Array & Exception Handling in C#