The multi -dimensional array in the c#
and [][]
[,]
When creating a multi -dimensional array in C#, there is a difference between
grammar. [][]
[,]
The array of an array (
[][]
double[][] ServicePoint = new double[10][];
Unified two -dimensional array (
[,]
This grammar creates a unified two -dimensional array, of which each element is the same size. Unlike the sawtooth array, it requires specified rows and indexes during the assignment period.
double[,] ServicePoint = new double[10, 9];
Why
Failure in (2)
Because is a unified two -dimensional array, the assignment must specify and indexes at the same time. It is meaningless, because it tries to access one -dimensional array in the two -dimensional array. double[][] ServicePoint = new double10;
The above is the detailed content of C# Multidimensional Arrays: What's the Difference Between `[][]` and `[,]`?. For more information, please follow other related articles on the PHP Chinese website!