C# Array Types | Situations of selecting Dimensions

One Dimension Array

If you have one student whose 5 subject's marks needed to be stored then, go for a one-dimensional array-like below

Marks[] m = new int[5];


100H
------------------------->
100H
10
102H
------------------------->
102H
20
104H
------------------------->
104H
30
106H
------------------------->
106H
40
108H
------------------------->
108H
50
   m

Here is an array of memory references  referencing 5 integer memory locations addressed by 100H, 102H, 104H, 106H, 108H and contains 5 integers 10,20,30,40,50 respectively.

Two Dimensional Array

If you need to store the 5 subjects marks of 15 students then go for 2D Array-like below,

Subjects, Marks[ , ]  = new int[15,5];

Three Dimensional Array

If you need to store and process 2 subject marks of 15 students of 3 sections then, go for a 3-dimensional array like below

Marks[ , , ] =new int[3,15,2]

No comments:

Post a Comment