What are the differences between using int[][] and int[,]?

.net, c#, multidimensional-array

Solution

The difference here is that the first sample, int[][] creates a jagged array, while the second creates a rectangular array (of dimension 2). In a jagged array each "column" can be of a different size. In a true multidimensional array, each "column" (in a dimension) is the same size. For more complete information see the Array section of the C# Programming Guide.

Problem

Coming from a perl background, I have always defined a 2D array using `int[][]`. I know you can use `int[,]` instead so what are the differences?

Original source

Related problems