using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace jagged_arrray
{
class Program
{
static void Main(string[] args)
{
int[][] arr = new int[4][];
arr[0] = new int[6];
arr[1] = new int[7];
arr[2] = new int[8];
arr[3] = new int[4];
// printing values of jagged array using nested for
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr[i].Length; j++)
Console.Write(arr[i][j] + "");
Console.WriteLine();
}
// assigning values of a jagged array using nested for
for (int i = 0; i < arr.GetLength(0); i++)
{
for (int j = 0; j < arr[i].Length; j++)
arr[i][j] = j + 1;
}
Console.ReadKey();
}
}
}
Friday, 8 February 2013
Jagged Array
Labels:
C# basics
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment