メソッドにint []を渡して別の配列と連結し、mainに戻してコンソールに出力しようとしています。ここ コードである:int []が現在のコンテキストに存在しません
//where preTemp is another array derived in previous method
public static int[] sesLayer(int[] preTemp)
{
//set two arrays for rtr and r1r0
int[] r1r0 = new int[2] { 0, 0 };
int[] RTR = new int[1] { 0 };
//add r1r0 to the preTemp int array
//set length of the new array to accomodate temp + r1r0
var length = new int[preTemp.Length + r1r0.Length];
r1r0.CopyTo(length, 0);
preTemp.CopyTo(length, length.Length);
//add RTR to the packet
return preTemp;
}
public static int[] preLayer(int tempData)
{
string binaryTemp = Convert.ToString(tempData, 2);
int DLC = binaryTemp.Length;
binaryTemp = binaryTemp.PadLeft(64, '0');
string binaryDLC = Convert.ToString(DLC, 2);
binaryDLC = binaryDLC.PadLeft(4, '0');
string prePacket = binaryDLC + binaryTemp;
//convert string to int[]
int[] preTemp = prePacket.Select(c => int.Parse(c.ToString())).ToArray();
return preTemp;
}
static void Main(string[] args)
{
int[] sesTemp = sesLayer(preTemp); //**error crops up here**
Console.Write(sesTemp);
Console.ReadLine();
}
及びINT TempDataを= 58。 助けていただければ幸いです。
「preTemp」はどこで宣言して初期化しますか? –
それは問題です、OPはそうではありません。 –
もう少し説明できますか? –