C# 如何声明和使用数组2维

C# 如何声明和使用数组2维,c#,multidimensional-array,C#,Multidimensional Array,我想这样做: uint8_t **t; int i; int m[100]; int i; t = calloc(n, sizeof(uint8*)); ... /* m is initialized in other function */ ... for (i=0;i<n;i++) { /* m[i] is calculated here */ *t = calloc(1, sizeof(uint8)*m[i]); } uint8\u t**t; in

我想这样做:

uint8_t **t;
int i;
int m[100];
int i;
t = calloc(n, sizeof(uint8*));
...
/* m is initialized in other function */
...
for (i=0;i<n;i++)
{
    /* m[i] is calculated here */        
    *t = calloc(1, sizeof(uint8)*m[i]);
}
uint8\u t**t;
int i;
int m[100];
int i;
t=calloc(n,sizeof(uint8*);
...
/*m在其他函数中初始化*/
...

对于(i=0;i列表是否适合您?然后您可以根据需要构建一个字节数组,并添加到整个列表集合对象中

    List<byte[]> myByteList = new List<byte[]>();
    for (whatever loop )
    {
       byte[] justOne = however you build one byte array;

       myByteList.Add( justOne );
    }

如何像C源代码一样使用C#?
t=new byte[n][];
?使用new byte[n][]或使用实际的2d数组字节[,]t=new byte[n,m]第一个不起作用,第二个我不能使用,因为m不固定请参阅文档:
    List<byte[]> myByteList = new List<byte[]>();
    for (whatever loop )
    {
       byte[] justOne = however you build one byte array;

       myByteList.Add( justOne );
    }
foreach( byte[] oneByteArray in myByteList )
{
   do something with the oneByteArray;
}