Code error with dynamic arrays

Hello everyone. How I declare a bidimensional structure (matrix) in which each cells contains a undefined-size array of int?

	void CheckSubMeshesLocation()
	{
		_subMeshesLocation = new int[(int)_gridN,(int)_gridM];
		for(int i=0;i<_gridN;i++)
		{
			for(int j=0;j<_gridM;j++)
			{
				for(int k=0;k<_subMeshArray.Length;k++)
				{
					_subMeshesLocation[i,j] = new int[_subMeshArray.Length];
				}
			}
		}
	}


	int[,][] _subMeshesLocation;

The line

_subMeshesLocation = new int[(int)_gridN,(int)_gridM];

should be

_subMeshesLocation = new int[(int)_gridN,(int)_gridM][];

Also you are declaring ijk arrays when you only need i*j arrays of variable length.

Here is an example of working code.

using UnityEngine;

public class NewBehaviourScript : MonoBehaviour {
     int[,][] _subMeshesLocation;
     int iSize=3;
     int jSize=3;

	 void Start(){
         _subMeshesLocation = new int[iSize, jSize][];
         for(int i=0; i<iSize; i++){
             for(int j=0; j<jSize; j++){
                 // for each (i, j) position creates an array of random size
                 int[] temp=new int[Random.Range(0, 10)];
                 // and then fills it with 0, 1, ... array.Length-1
                 for(int k=0; k<temp.Length; k++){
                     temp[k]=k;
                 }
                 _subMeshesLocation[i, j]=temp;
             }
         }

         // prints back all the values
         for(int i=0; i<_subMeshesLocation.GetLength(0); i++) {
             for(int j=0; j<_subMeshesLocation.GetLength(1); j++) {
                 int[] temp=_subMeshesLocation[i, j];
                 for(int k=0; k<temp.Length; k++) {
                     Debug.Log(temp[k]);
                 }
             }
         }
     }
}