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

More Related Content

PPTX
C# Arrays
PPTX
PDF
Array and Collections in c#
PPTX
Array in C# 3.5
PPTX
Arrays in c language
PPTX
Array in c#
PPTX
C++ programming (Array)
C# Arrays
Array and Collections in c#
Array in C# 3.5
Arrays in c language
Array in c#
C++ programming (Array)

What's hot (20)

PDF
intorduction to Arrays in java
PPTX
Array lecture
PPTX
Arrays in java language
PPT
02 c++ Array Pointer
PPT
Java: Introduction to Arrays
PPT
Array in Java
PPTX
C++ lecture 04
PPT
Java Arrays
PPTX
Arrays in java
PDF
Array data structure
PPT
Array
PPT
Data Structure Midterm Lesson Arrays
PDF
An Introduction to Programming in Java: Arrays
PPTX
PPTX
Computer programming 2 Lesson 13
PPTX
PPT
Lec 25 - arrays-strings
PPTX
Arrays in Java
PPT
C++ Arrays
PPTX
6 arrays injava
intorduction to Arrays in java
Array lecture
Arrays in java language
02 c++ Array Pointer
Java: Introduction to Arrays
Array in Java
C++ lecture 04
Java Arrays
Arrays in java
Array data structure
Array
Data Structure Midterm Lesson Arrays
An Introduction to Programming in Java: Arrays
Computer programming 2 Lesson 13
Lec 25 - arrays-strings
Arrays in Java
C++ Arrays
6 arrays injava
Ad

Similar to 7array in c# (20)

PPTX
PPTX
Arrays in .Net Programming Language.pptx
PPTX
Arrays.pptx
PDF
Learn C# Programming - Nullables & Arrays
PPTX
Arrays.pptx
PDF
Functions, Strings ,Storage classes in C
PPTX
2CPP06 - Arrays and Pointers
PPTX
Chapter-Five.pptx
ODP
(2) collections algorithms
DOC
Arrays In General
PPTX
MODUL new hlgjg thaybkhvnghgpv7E_02.pptx
PPTX
array.pptx ppt ggsipu bpit delhi rohini.
PPTX
ARRAYS.pptx
PPTX
Functions and Arraysfgdfgdfgdfgdfgdg.pptx
PPTX
c unit programming arrays in detail 3.pptx
PPTX
Programming fundamentals week 12.pptx
PPTX
Array & Exception Handling in C# (CSharp)
PPTX
Array definition and uses in computer.pptx
PPTX
Lesson 7-computer programming case study-FINAL.pptx
PPT
Arrays
Arrays in .Net Programming Language.pptx
Arrays.pptx
Learn C# Programming - Nullables & Arrays
Arrays.pptx
Functions, Strings ,Storage classes in C
2CPP06 - Arrays and Pointers
Chapter-Five.pptx
(2) collections algorithms
Arrays In General
MODUL new hlgjg thaybkhvnghgpv7E_02.pptx
array.pptx ppt ggsipu bpit delhi rohini.
ARRAYS.pptx
Functions and Arraysfgdfgdfgdfgdfgdg.pptx
c unit programming arrays in detail 3.pptx
Programming fundamentals week 12.pptx
Array & Exception Handling in C# (CSharp)
Array definition and uses in computer.pptx
Lesson 7-computer programming case study-FINAL.pptx
Arrays
Ad

More from Sireesh K (20)

PPTX
Cn10
PPTX
chanakya neeti
PPTX
chanakya neeti
DOCX
What is mvc
PPTX
PPTX
31cs
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
PPTX
Cn10
chanakya neeti
chanakya neeti
What is mvc
31cs

Recently uploaded (20)

PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Cell Structure & Organelles in detailed.
PDF
Trump Administration's workforce development strategy
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Classroom Observation Tools for Teachers
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
master seminar digital applications in india
PPTX
Pharma ospi slides which help in ospi learning
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Weekly quiz Compilation Jan -July 25.pdf
Final Presentation General Medicine 03-08-2024.pptx
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Cell Structure & Organelles in detailed.
Trump Administration's workforce development strategy
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Abdominal Access Techniques with Prof. Dr. R K Mishra
Classroom Observation Tools for Teachers
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
master seminar digital applications in india
Pharma ospi slides which help in ospi learning

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