问题描述
解决方案
b是int型
char m in b
这里char写成int试试
解决方案二:
result = result + m + ",";
->
result = result + m.ToString() + ",";
解决方案三:
int[] a = new int [10];
for (int i = 0; i < 10; i++)
{
Console.WriteLine("请输入整数:");
a[i] = Convert.ToInt32(Console.ReadLine());
}
string num="";
foreach (int s in a)
{
num = num + s + ",";
}
Console.WriteLine("该数组为:{0}", num);
int[] b = new int[9];
int k = 0;
while (k < 9)
{
int temp;
temp = a[k] + a[k + 1];
b[k] = temp;
k++;
}
string result="";
foreach (char m in b)
{
result = result + m + ",";
}
Console.WriteLine("将第一个数组相邻两项相加,得出的新数组为{0}" , result);
解决方案五:
新人有很多不懂得地方,请大神们多多关照啦,谢谢大家