C#定义一个8位的一维空数组,按下button0,插入数据"00"到第0位,替换之前的数据,按下button1,插入数据"01"到第1位,,,,,,,,,,一直到按下button7,发插入数据"07"到第7位。插入后替换掉数组之前的数据。。请问这段代码怎么写。
byte[] arr = new byte[8];
void button1_Click(object sender, EventArgs e)
{
arr[0] = (byte)Convert.ToInt32("00", 16);
}
别的类似
int[] myIntArray = new int[3];
private void button1_Click(object sender, System.EventArgs e)
{
myIntArray[0] = 1;
}
private void button2_Click(object sender, System.EventArgs e)
{
myIntArray[1] = 2;
}
你这逻辑有问题啊,既然是空数组怎么能替换之前的数据,如果之前有数据直接用replace("sad","11"); 复杂一点的替换可以用Regex。