SlideShare a Scribd company logo
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)

PPTX
FUNDAMENTAL OF C
KRUNAL RAVAL
 
PPTX
Abstract Data Types
karthikeyanC40
 
PPTX
Advanced VB: Review of the basics
robertbenard
 
PPT
Methods in C#
Prasanna Kumar SM
 
PPT
Data types and Operators
raksharao
 
PPTX
Constants and variables in c programming
Chitrank Dixit
 
PPTX
Python l3
Aishwarya Deshmukh
 
PPT
Basic of c &c++
guptkashish
 
PPT
Ppt lesson 08
Linda Bodrie
 
PPTX
data structures and algorithms Unit 1
infanciaj
 
PPTX
Operators in java
Then Murugeshwari
 
PPTX
Constant and variacles in c
yash patel
 
PPT
Ppt lesson 07
Linda Bodrie
 
PPT
Frequently asked questions in c
David Livingston J
 
PPT
Frequently asked questions in c
David Livingston J
 
PPT
Abstract data types
Hoang Nguyen
 
FUNDAMENTAL OF C
KRUNAL RAVAL
 
Abstract Data Types
karthikeyanC40
 
Advanced VB: Review of the basics
robertbenard
 
Methods in C#
Prasanna Kumar SM
 
Data types and Operators
raksharao
 
Constants and variables in c programming
Chitrank Dixit
 
Basic of c &c++
guptkashish
 
Ppt lesson 08
Linda Bodrie
 
data structures and algorithms Unit 1
infanciaj
 
Operators in java
Then Murugeshwari
 
Constant and variacles in c
yash patel
 
Ppt lesson 07
Linda Bodrie
 
Frequently asked questions in c
David Livingston J
 
Frequently asked questions in c
David Livingston J
 
Abstract data types
Hoang Nguyen
 

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

PPT
07 Arrays
maznabili
 
PDF
C sharp chap6
Mukesh Tekwani
 
PPT
For Beginners - C#
Snehal Harawande
 
PPTX
Visual Programing basic lectures 7.pptx
Mrhaider4
 
PPTX
arrays in c# including Classes handling arrays
JayanthiM19
 
PPTX
Aspdot
Nishad Nizarudeen
 
PPTX
07. Arrays
Intro C# Book
 
PPTX
7array in c#
Sireesh K
 
PPTX
arrays-120712074248-phpapp01
Abdul Samee
 
PPTX
Arrays C#
Raghuveer Guthikonda
 
PDF
Learn C# Programming - Nullables & Arrays
Eng Teong Cheah
 
PDF
Intake 38 5
Mahmoud Ouf
 
PPTX
16. Arrays Lists Stacks Queues
Intro C# Book
 
PDF
Dr archana dhawan bajaj - csharp fundamentals slides
Dr-archana-dhawan-bajaj
 
PPTX
Arrays in .Net Programming Language.pptx
vanithachezian
 
PDF
Programming with C++
ssuser802d47
 
PPTX
Loops in C# for loops while and do while loop.
Abid Kohistani
 
PPTX
Intro to C# - part 2.pptx emerging technology
worldchannel
 
PDF
Understanding C# in .NET
mentorrbuddy
 
PPTX
NET Training series session for beginers
VikramJothyPrakash1
 
07 Arrays
maznabili
 
C sharp chap6
Mukesh Tekwani
 
For Beginners - C#
Snehal Harawande
 
Visual Programing basic lectures 7.pptx
Mrhaider4
 
arrays in c# including Classes handling arrays
JayanthiM19
 
07. Arrays
Intro C# Book
 
7array in c#
Sireesh K
 
arrays-120712074248-phpapp01
Abdul Samee
 
Learn C# Programming - Nullables & Arrays
Eng Teong Cheah
 
Intake 38 5
Mahmoud Ouf
 
16. Arrays Lists Stacks Queues
Intro C# Book
 
Dr archana dhawan bajaj - csharp fundamentals slides
Dr-archana-dhawan-bajaj
 
Arrays in .Net Programming Language.pptx
vanithachezian
 
Programming with C++
ssuser802d47
 
Loops in C# for loops while and do while loop.
Abid Kohistani
 
Intro to C# - part 2.pptx emerging technology
worldchannel
 
Understanding C# in .NET
mentorrbuddy
 
NET Training series session for beginers
VikramJothyPrakash1
 
Ad

Recently uploaded (20)

PDF
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
PDF
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
PDF
Plant Control_EST_85520-01_en_AllChanges_20220127.pdf
DarshanaChathuranga4
 
PDF
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
PDF
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
PDF
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PPTX
Work at Height training for workers .pptx
cecos12
 
PPTX
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
PPTX
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
PDF
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
PDF
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
PDF
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
PDF
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
PPTX
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
DOCX
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
PDF
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PDF
June 2025 - Top 10 Read Articles in Network Security and Its Applications
IJNSA Journal
 
PDF
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
Decision support system in machine learning models for a face recognition-bas...
TELKOMNIKA JOURNAL
 
Module - 5 Machine Learning-22ISE62.pdf
Dr. Shivashankar
 
Plant Control_EST_85520-01_en_AllChanges_20220127.pdf
DarshanaChathuranga4
 
bs-en-12390-3 testing hardened concrete.pdf
ADVANCEDCONSTRUCTION
 
Authentication Devices in Fog-mobile Edge Computing Environments through a Wi...
ijujournal
 
Designing for Tomorrow – Architecture’s Role in the Sustainability Movement
BIM Services
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
Work at Height training for workers .pptx
cecos12
 
Kel.3_A_Review_on_Internet_of_Things_for_Defense_v3.pptx
Endang Saefullah
 
Bharatiya Antariksh Hackathon 2025 Idea Submission PPT.pptx
AsadShad4
 
NFPA 10 - Estandar para extintores de incendios portatiles (ed.22 ENG).pdf
Oscar Orozco
 
How to Buy Verified CashApp Accounts IN 2025
Buy Verified CashApp Accounts
 
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
Module - 4 Machine Learning -22ISE62.pdf
Dr. Shivashankar
 
FSE_LLM4SE1_A Tool for In-depth Analysis of Code Execution Reasoning of Large...
cl144
 
Engineering Geology Field Report to Malekhu .docx
justprashant567
 
Artificial Neural Network-Types,Perceptron,Problems
Sharmila Chidaravalli
 
Functions in Python Programming Language
BeulahS2
 
June 2025 - Top 10 Read Articles in Network Security and Its Applications
IJNSA Journal
 
CLIP_Internals_and_Architecture.pdf sdvsdv sdv
JoseLuisCahuanaRamos3
 
Ad

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#