Lab1.6 Array
Lab1.6 Array
// Main Method
public void ArrayFirstExamples()
{
// so on...
intArray[2] = 30;
intArray[3] = 40;
intArray[4] = 50;
Console.WriteLine("");
Console.Write("For-each loop :");
Console.WriteLine("");
Console.Write("while loop :");
// using while loop
int j = 0;
while (j < intArray.Length)
{
Console.Write(" " + intArray[j]);
j++;
}
Console.WriteLine("");
Console.Write("Do-while loop :");
The multidimensional array has multiple rows for storing values. It is also known as a
Rectangular C# Array. It can be a 2D, 3D, or more array. A nested loop was required to
store and access the array's values. Therefore, you must use commas inside the square
brackets to create a multidimensional array.
Code:
{
for (int j = 0; j < 3; j++)
Console.WriteLine();
System.Console.WriteLine();