在我的代码中,
int x;
int y;
x = 7;
if (x == y)
{
Console.WriteLine("The numbers are the same!");
}
else
{
Console.WriteLine("The numbers are different.");
}
Console.ReadLine();
for (int i = 0; i < y; i--)
{
Console.WriteLine("{0} sheep!", i);
}
Console.ReadLine();
string[] colors = new string[y];
colors[0] = "green";
colors[1] = "yellow";
colors[y] = "red";
Console.WriteLine("Your new code is {0}.", Code(x, y));
Console.ReadLine();
}
static int Code(int myX, int myY)
{
int answer = myX * myX - myY;
}
}
}
出现了一个错误,错误信息如下:
'ConsoleApplication1.Program.Code(int, int)': 不是所有的代码路径都返回值。
我不确定代码哪里有问题。有解决方案吗?