如何在c#中简要声明多个字节数组

问题描述 投票:0回答:2

例如,我想声明以下内容,但希望有一个简单的方法。然后分别使用它们中的每一个:

$byte[] image_bt_update_1 = null;
$byte[] image_bt_update_2 = null;
$byte[] image_bt_update_3 = null;
$byte[] image_bt_update_4 = null;
c# byte declare
2个回答
1
投票

如果您使用的是C#,则可以使用数组数组

byte[][] image_tb_update = new byte[4][_N];

其中_N是image_tb_update数组的维度

并将其称为

image_tb_update[0][0]... image_tb_update[0][_N-1]
image_tb_update[3][0]... image_tb_update[3][_N-1]

初始化所有元素

for (int i=0;i<3;i++)
   for (int j=0;i<_N;j++)
      image_tb_update[i][j]=0;

-1
投票

由于它们是相同的类型,您可以将它们替换为:

$byte[] image_bt_update_1 = null, image_bt_update_2 = null, image_bt_update_3 = null, image_bt_update_4 = null;

© www.soinside.com 2019 - 2024. All rights reserved.