What is a gear array?

What is a gear array (in C #)? Any examples and when to use it ....

+42
c # jagged-arrays
Apr 05 '10 at 3:16
source share
7 answers

A slowed array is an array of arrays.

string[][] arrays = new string[5][]; 

This is a set of five different string arrays, each of which can have a different length (they can also be the same length, but the bottom line is that they are not guaranteed).

 arrays[0] = new string[5]; arrays[1] = new string[100]; ... 

This is different from a 2D array, where it is rectangular, that is, each row has the same number of columns.

 string[,] array = new string[3,5]; 
+52
Apr 05 '10 at 3:18
source share

An uneven array is the same in any language, but where you have a 2+ dimensional array with different array lengths in the second and subsequent arrays.

 [0] - 0, 1, 2, 3, 4 [1] - 1, 2, 3 [2] - 5, 6, 7, 8, 9, 10 [3] - 1 [4] - [5] - 23, 4, 7, 8, 9, 12, 15, 14, 17, 18 
+9
Apr 05 '10 at 3:20
source share

You can find more information here: http://msdn.microsoft.com/en-us/library/2s05feca.aspx

Also:

An egg array is an array whose elements are arrays. Elements of the gear array can be of different sizes and sizes. An FMD array is sometimes called an "array of arrays." The following examples show how to declare, initialize, and access notched arrays.

The following is a declaration of a one-dimensional array with three elements, each of which is a one-dimensional array of integers:

 jaggedArray[0] = new int[5]; jaggedArray[1] = new int[4]; jaggedArray[2] = new int[2]; 

or

 jaggedArray[0] = new int[] { 1, 3, 5, 7, 9 }; jaggedArray[1] = new int[] { 0, 2, 4, 6 }; jaggedArray[2] = new int[] { 11, 22 }; 
+5
Apr 05 '10 at 3:21
source share

Although the best answer was chosen by the owner of the question, but I want to introduce the following code to make a clear array more understandable.

 using System; class Program { static void Main() { // Declare local jagged array with 3 rows. int[][] jagged = new int[3][]; // Create a new array in the jagged array, and assign it. jagged[0] = new int[2]; jagged[0][0] = 1; jagged[0][1] = 2; // Set second row, initialized to zero. jagged[1] = new int[1]; // Set third row, using array initializer. jagged[2] = new int[3] { 3, 4, 5 }; // Print out all elements in the jagged array. for (int i = 0; i < jagged.Length; i++) { int[] innerArray = jagged[i]; for (int a = 0; a < innerArray.Length; a++) { Console.Write(innerArray[a] + " "); } Console.WriteLine(); } } } 

The output will be

 1 2 0 3 4 5 

Cell arrays are used to store data in variable-length strings.

Check out this MSDN blog post for more information.

+4
May 01 '13 at 16:29
source share

A stub array is one in which you declare the number of rows at the time of declaration, but you declare the number of columns at run time or also at the user's choice, just its average value, when you want a different number of columns to be used in each JAGGED array, this happening

 int[][] a = new int[6][];//its mean num of row is 6 int choice;//thats i left on user choice that how many number of column in each row he wanna to declare for (int row = 0; row < a.Length; row++) { Console.WriteLine("pls enter number of colo in row {0}", row); choice = int.Parse(Console.ReadLine()); a[row] = new int[choice]; for (int col = 0; col < a[row].Length; col++) { a[row][col] = int.Parse(Console.ReadLine()); } } 
+2
Jan 18 '15 at 17:22
source share

Jagged array is an array with other arrays contained inside.

An egg array is an array in which the number of rows is fixed, but the number of columns is not fixed.

Code for jagged array in C # for window form application

 int[][] a = new int[3][]; a[0]=new int[5]; a[1]=new int[3]; a[2]=new int[1]; int i; for(i = 0; i < 5; i++) { a[0][i] = i; ListBox1.Items.Add(a[0][i].ToString()); } for(i = 0; i < 3; i++) { a[0][i] = i; ListBox1.Items.Add(a[0][i].ToString()); } for(i = 0; i < 1; i++) { a[0][i] = i; ListBox1.Items.Add(a[0][i].ToString()); } 

As you can see from the above program, the number of rows is not fixed to 3, but the number of columns is not fixed. Thus, we took three different column values, i.e. 5, 3 and 1. The keyword ListBox1 used in this code refers to the list that we will use in the form of a window to see the result by pressing a button, which will also be used as a window. All programming done here is on the button.

0
Oct 10 2018-11-11T00:
source share

Jagged Array is a multidimensional array with a different number of lines.

0
Dec 29 '17 at 9:54 on
source share



All Articles