SlideShare una empresa de Scribd logo
1 de 6
C# Tutorial
Part 7:
Arrays
www.sirykt.blogspot.com
• Like other programming languages, array in C# is a group of similar types
of elements that have contiguous memory location.
• In C#, array is an object of base type System.Array. In C#, array index
starts from 0. We can store only fixed set of elements in C# array.
• Advantages of C# Array
• Code Optimization (less code)
• Random Access
• Easy to traverse data
• Easy to manipulate data
• Easy to sort data etc.
• Disadvantages of C# Array
• Fixed size
• C# Array Types
• There are 3 types of arrays in C# programming:
• Single Dimensional Array
• Multidimensional Array
• Jagged Array
• C# Single Dimensional Array
• To create single dimensional array, you need to use square brackets
[] after the type.
• int[] arr = new int[5];//creating array
• You cannot place square brackets after the identifier.
• int arr[] = new int[5];//compile time error
• C# Multidimensional Arrays
• The multidimensional array is also known as rectangular arrays in
C#. It can be two dimensional or three dimensional. The data is
stored in tabular form (row * column) which is also known as matrix.
• To create multidimensional array, we need to use comma inside the
square brackets. For example:
• int[,] arr=new int[3,3];//declaration of 2D array
• int[,,] arr=new int[3,3,3];//declaration of 3D array
• C# Jagged Arrays
• In C#, jagged array is also known as "array of arrays" because its
elements are arrays. The element size of jagged array can be different.
• Declaration of Jagged array
• Let's see an example to declare jagged array that has two elements.
• int[][] arr = new int[2][];
• Initialization of Jagged array
• Let's see an example to initialize jagged array. The size of elements can
be different.
• arr[0] = new int[4];
• arr[1] = new int[6];
• Initialization and filling elements in Jagged array
• Let's see an example to initialize and fill elements in jagged array.
• arr[0] = new int[4] { 11, 21, 56, 78 };
• arr[1] = new int[6] { 42, 61, 37, 41, 59, 63 };
• Here, size of elements in jagged array is optional. So, you can write above
code as given below:
• arr[0] = new int[] { 11, 21, 56, 78 };
SIRYKT
Sharing Knowledge is Learning
For more updates
For more visit our website www.sirykt.blogspot.com

Más contenido relacionado

La actualidad más candente

02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
Tareq Hasan
 
Array
ArrayArray
Array
Hajar
 
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
Maulen Bale
 
Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-strings
Princess Sam
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
irdginfo
 

La actualidad más candente (20)

intorduction to Arrays in java
intorduction to Arrays in javaintorduction to Arrays in java
intorduction to Arrays in java
 
Array lecture
Array lectureArray lecture
Array lecture
 
Arrays in java language
Arrays in java languageArrays in java language
Arrays in java language
 
02 c++ Array Pointer
02 c++ Array Pointer02 c++ Array Pointer
02 c++ Array Pointer
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
Array in Java
Array in JavaArray in Java
Array in Java
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Java Arrays
Java ArraysJava Arrays
Java Arrays
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Array data structure
Array data structureArray data structure
Array data structure
 
Array
ArrayArray
Array
 
Data Structure Midterm Lesson Arrays
Data Structure Midterm Lesson ArraysData Structure Midterm Lesson Arrays
Data Structure Midterm Lesson Arrays
 
An Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: ArraysAn Introduction to Programming in Java: Arrays
An Introduction to Programming in Java: Arrays
 
Array
ArrayArray
Array
 
Computer programming 2 Lesson 13
Computer programming 2  Lesson 13Computer programming 2  Lesson 13
Computer programming 2 Lesson 13
 
Arrays
ArraysArrays
Arrays
 
Lec 25 - arrays-strings
Lec 25 - arrays-stringsLec 25 - arrays-strings
Lec 25 - arrays-strings
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
6 arrays injava
6 arrays injava6 arrays injava
6 arrays injava
 

Similar a 7array in c#

Arrays In General
Arrays In GeneralArrays In General
Arrays In General
martha leon
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
dfsdg3
 

Similar a 7array in c# (20)

Array
ArrayArray
Array
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.pptx
 
Learn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & ArraysLearn C# Programming - Nullables & Arrays
Learn C# Programming - Nullables & Arrays
 
Arrays.pptx
Arrays.pptxArrays.pptx
Arrays.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
 
2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers2CPP06 - Arrays and Pointers
2CPP06 - Arrays and Pointers
 
Chapter-Five.pptx
Chapter-Five.pptxChapter-Five.pptx
Chapter-Five.pptx
 
(2) collections algorithms
(2) collections algorithms(2) collections algorithms
(2) collections algorithms
 
Arrays In General
Arrays In GeneralArrays In General
Arrays In General
 
ARRAYS.pptx
ARRAYS.pptxARRAYS.pptx
ARRAYS.pptx
 
Programming fundamentals week 12.pptx
Programming fundamentals week 12.pptxProgramming fundamentals week 12.pptx
Programming fundamentals week 12.pptx
 
Array & Exception Handling in C# (CSharp)
Array & Exception Handling in C# (CSharp)Array & Exception Handling in C# (CSharp)
Array & Exception Handling in C# (CSharp)
 
Arrays
ArraysArrays
Arrays
 
Arrays.pptx
 Arrays.pptx Arrays.pptx
Arrays.pptx
 
4.ArraysInC.pdf
4.ArraysInC.pdf4.ArraysInC.pdf
4.ArraysInC.pdf
 
Cunit3.pdf
Cunit3.pdfCunit3.pdf
Cunit3.pdf
 
Arrays in c v1 09102017
Arrays in c v1 09102017Arrays in c v1 09102017
Arrays in c v1 09102017
 
Arraysincv109102017 180831194256
Arraysincv109102017 180831194256Arraysincv109102017 180831194256
Arraysincv109102017 180831194256
 
C
CC
C
 
Arrays In C Language
Arrays In C LanguageArrays In C Language
Arrays In C Language
 

Más de Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
31cs
31cs31cs
31cs
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 

Último

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Último (20)

ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 

7array in c#

  • 2. • Like other programming languages, array in C# is a group of similar types of elements that have contiguous memory location. • In C#, array is an object of base type System.Array. In C#, array index starts from 0. We can store only fixed set of elements in C# array. • Advantages of C# Array • Code Optimization (less code) • Random Access • Easy to traverse data • Easy to manipulate data • Easy to sort data etc. • Disadvantages of C# Array • Fixed size • C# Array Types • There are 3 types of arrays in C# programming: • Single Dimensional Array • Multidimensional Array • Jagged Array
  • 3. • C# Single Dimensional Array • To create single dimensional array, you need to use square brackets [] after the type. • int[] arr = new int[5];//creating array • You cannot place square brackets after the identifier. • int arr[] = new int[5];//compile time error • C# Multidimensional Arrays • The multidimensional array is also known as rectangular arrays in C#. It can be two dimensional or three dimensional. The data is stored in tabular form (row * column) which is also known as matrix. • To create multidimensional array, we need to use comma inside the square brackets. For example: • int[,] arr=new int[3,3];//declaration of 2D array • int[,,] arr=new int[3,3,3];//declaration of 3D array
  • 4. • C# Jagged Arrays • In C#, jagged array is also known as "array of arrays" because its elements are arrays. The element size of jagged array can be different. • Declaration of Jagged array • Let's see an example to declare jagged array that has two elements. • int[][] arr = new int[2][]; • Initialization of Jagged array • Let's see an example to initialize jagged array. The size of elements can be different. • arr[0] = new int[4]; • arr[1] = new int[6]; • Initialization and filling elements in Jagged array • Let's see an example to initialize and fill elements in jagged array. • arr[0] = new int[4] { 11, 21, 56, 78 }; • arr[1] = new int[6] { 42, 61, 37, 41, 59, 63 }; • Here, size of elements in jagged array is optional. So, you can write above code as given below: • arr[0] = new int[] { 11, 21, 56, 78 };
  • 6. For more updates For more visit our website www.sirykt.blogspot.com