将整个数组值分配给c#中的另一个变量?

时间:2012-11-23 07:56:06

标签: c#

我有一个数组,我想将它分配给另一个数组变量。这是代码

for (int i = 0; i < length; i++)
        {
            arr1[i] = Convert.ToByte(Tag_uid.Substring(2 * i, 2), 16);
        }



        //Create an array to hold the Command Packet
        byte[] CommandPacket = new byte[9];


        CommandPacket[0] = arr1;   //ERROR: cannot convert type byte[] to byte

如何将整个数组值分配给commandpacket[0]

1 个答案:

答案 0 :(得分:0)

怎么样

for (int i = 0; i < length; i++)
{
    arr1[i] = Convert.ToByte(Tag_uid.Substring(2 * i, 2), 16);
}

byte[][] CommandPacket = new byte[9][];

CommandPacket[0] = arr1;