How to get the lenght an array?

I have this code:

private Vector3[,] roomLocalization = new[,]
{
   {new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0)},
   {new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0)},
   {new Vector3(0,0,0)}
};

I dont want to get the lenght of one array like “roomLocalization.GetLength(0)” and I need get the number of lines, in this case are 3.There is a command to get this?

roomLocalization.Length;

Since it’s a multidimensional array you have to use GetLength(0) for the first dimension and GetLength(1) for the second.

Btw: You don’t initialize your array completely. A multidimensional array can’t have different length in a dimension. So a 2d-array is always a rectangle / table. It can’t have empty cells. A 3d array is always a cube. It sounds like you think you’re using jagged arrays (arrays in arrays) but you don’t. A jagged array would look like this:

Vector3[][] myarray;

edit
Here’s an example how a jagged array would look like in your case:

private Vector3[][] roomLocalization = new Vector3[][]
{
    new Vector3[]{new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0)},
    new Vector3[]{new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0), new Vector3(0,0,0)},
    new Vector3[]{new Vector3(0,0,0)}
};

Now you have only simple one dimensional arrays. So the “row” count is simply the length of the outer array:

int numRows = roomLocalization.Length;
int numCol0 = roomLocalization[0].Length;
int numCol1 = roomLocalization[1].Length;

Vector3 v = roomLocalization[1][2];  // 3rd element in 2ed "row" / array

I dont want to get the lenght of one array like "roomLocalization.GetLength(0). I need get the number of lines, in this case are 3

The number of “lines”, 3, is what roomLocalization.GetLength(0) gives you…