true

Find the best tutors and institutes for C# .NET

Find Best C# .NET

Please select a Category.

Please select a Locality.

No matching category found.

No matching Locality found.

Outside India?

Search for topics

What Is An Array? Explain Its Type.

N
Neelam S.
02/08/2017 0 0

Array: Array is a collection of similar type of data in an array varaiable. Array start with Zero Index and maximum length of array is total element - 1. i.e., Suppose n is the length of array, total element in array is n-1. In memory it occupy the contiguous memory locations. The lowest address is the first element of an array and highest is the last element of an array.

A[0]

A[1]

A[2]

A[3]

A[4]

A[5]

A[6]

A[7]

Declare an Array:

Int[] A =new int [8];

  1. Datatype is used to specify the type of an array.
  2. [] specifies the rank of an array or number of elements store in an array.
  3. Array_name specifies the name of an array.
  4. New keyword is used to allocate the memory block for an array.

Assigning value in an array:

Example 1:

Int[] A=new int[8];

A[0]=10;

A[1]=20;

Example 2:

Int[] A=new int[8]{10,20,30,40,50,60,70};

Here we declare and assign value in an array together.

Example 3:

String[] flowers=new string[]{“Lotus”,”Lilly”,”Rose”};

Here also assign value in an array but without specify the array size. In memory location it will take size of an array depend on the value we assign.

Types of Array

  1. Single Dimension array
  2. Multi Dimension Array
  3. Jagged Array

1. Single Dimension Array:

int[] x=new int[5];

string[] food=new string[]{“Pizza”,”Burger”,”Pasta”};

In single dimension there is only one dimension and start with 0 index.

2. Multi Dimension Array:

Multi Dimension array are 2-D array or 3-D array.

2-D array can be thought of a table or in matrix format.  Which has x as number of rows and y as number of columns. Example

Int[,] B=new int[2,3];

Here 2 means number of rows and 3 stands for number of columns.

B[0][0]

B[0][1]

B[0][2]

B[1][0]

B[1][1]

B[1][2]

Initialize an array of 2-D

Int[,] D=new int[3,3]{{1,2,3},{4,5,6},{7,8,9}};

1

2

3

4

5

6

7

8

9

3. Jagged Array:

Jagged Array is an array whose elements are array. It is call array within array. The dimension and size of jagged array is different in each element.

Declaration of jagged array:

Int[][] K=new int[2][];

In the above statement 2 is number of rows in a jagged array.

Initialize value in an array:

K[0]=new int[5];

K[1]=new int[2];

K[0]-is the first element of array and now size of this array is total element-1.

K[1]-is the 2nd row of an array and total element-1.

K[0][0]

K[0][1]

K[0][1]

K[0][2]

K[0][3]

K[1][0]

K[1][1]

K[1][2]

 

 

0 Dislike
Follow 0

Please Enter a comment

Submit

Other Lessons for You

Facebook Analytics
Assume how the Facebook application will store the millions of customer's record in real-time: facebook = { 'jose': { 'name': 'jose', 'age': 33, 'hobby': , # cricket,football 'mobile': 1111111111, 'email':...

Logeswaran | 03/09/2019

0 0
0

Multi-core CPU utilization using Task Parallel Library in c#
Nowadays, we are using multiple core systems. We must write our .NET applications in such a way that we must utilise the complete computing power of the machine. The parallel task library(TPL) allows...

Ketan Agnihotri | 12/01/2019

0 0
0

Why a function in C# requires "Return type"??
- Basically , a Method is a piece of code used for the re-usability purpose. - Method is of 2 types Function and Procedure - Function is a method which returns a value to the calling place Function...

Raga Deepthi G. | 25/09/2018

0 0
0

What are various validator in ASP.NET 2.0 and features common in all validation control in ASP.NET
Control to validate an error message. Are common feature in all the controls.Various validators are requiredfeild validator ,compare validator ,regular expression validator,custom validator,range validator...

Suprio Dutta | 29/06/2018

0 0
0

What are Various Types of Exception in C#
ArgumentException, ArgumentNullException, and ArgumentOutOfRangeException. NullReferenceException, IndexOutOfRangeException, SQL exceptions Stack Overflow Exception, Invalid Castexception ArgumentException...

Suprio Dutta | 28/06/2018

0 0
0
X

Looking for C# .NET Classes?

Find best tutors for C# .NET Classes by posting a requirement.

  • Post a learning requirement
  • Get customized responses
  • Compare and select the best

Looking for C# .NET Classes?

Find best C# .NET Classes in your locality on UrbanPro

Post your learning requirement

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more