background image

C# Console Application,

<< Single dimension array | Jagged Arrays >>
<< Single dimension array | Jagged Arrays >>
e.g.
string[,] studentdetails = new string [10,2];
Index positions of array elements.
0,0 0,1
1,0 1,1
2,0 2,1
3,0 3,1
...
10,0 10,1

studentdetails(0,0) = "Manoj"
studentdetails(0,1) = "Malik"

To display "Malik" we need to use the index position of the array and say ,
Studentdetails [0,1].

Example 2.

We will create a C# Console Application, which will accept Student Name, Address and
city name and display it on the Console.
string [,] arrsummary = new string[3, 3];
int i=0, j=0;

//As we wanted just 3 columns we have set it to 2, else if
u want to be two only then while declaring the array make
it (2,2) as the lower index is 0.

for(i = 0;i<=2;i++)
{
for(j = 0;j<=2;j++)
{
Console.WriteLine("Enter the value for " + i + "
row and " + j + " column, Summary");
arrsummary[i, j] = Console.ReadLine();
}
}


Console.WriteLine();

//Display the values in the summary array.
for(i = 0;i<=2;i++)
{