11 12 11 14 15 16
Users Online
· Guests Online: 114
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
Jagged Array Program in C#
Jagged Array Program in C#
This is a C# Program to demonstrate jagged arrays.
Problem Description
This C# Program Demonstrates Jagged Arrays.
Problem Solution
Here Jagged Arrays can store efficiently many rows of varying lengths. Any type of data, reference or value, can be used.
Program/Source Code
Here is source code of the C# Program to Demonstrate Jagged Arrays. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Demonstrate Jagged Arrays */ using System; class Program { static void Main() { int[][] jag = new int[3][]; jag[0] = new int[2]; jag[0][0] = 11; jag[0][1] = 12; jag[1] = new int[1] {11}; jag[2] = new int[3] { 14,15, 16 }; for (int i = 0; i < jag.Length; i++) { int[] innerArray = jag[i]; for (int a = 0; a < innerArray.Length; a++) { Console.WriteLine(innerArray[a] + " "); } } Console.Read(); } }
Program Explanation
This C# Program is used to Demonstrate Jagged Arrays. The elements of a jagged array can be of different dimensions and sizes. A jagged array is sometimes called an “array of arrays.” Create a new array in the jagged array, and assign its coefficient values, and form second row and third row by using array initialize.
Here Jagged Arrays can store efficiently many rows of varying lengths. Any type of data, reference or value, can be used. For loop is used to print the jagged array element values.
Runtime Test Cases
Jagged Array Program in C#
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.