我有一个我在标题中提到的问题,只需要一些帮助来解决这个烦人的错误。
这是我的代码:
bool moreEmp;
int arrayplus;
string doitagain;
arrayplus = -1;
string[,] employees = new string[10, 10];
do
{
arrayplus++;
Console.WriteLine("please enter your employee's number");
employees[0, arrayplus] = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("please enter your employee's name");
employees[1, arrayplus] = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("please enter your employee's age");
employees[2, arrayplus] = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("please enter your employee's official position ");
employees[3, arrayplus] = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("please enter your employee's salary");
employees[4, arrayplus] = Console.ReadLine();
Console.ReadLine();
Console.WriteLine("Do you want to add more employees into this list? y or n.");
doitagain = Console.ReadLine();
if (doitagain == "y" || doitagain == "Y")
{
moreEmp = true;
}
else if (doitagain == "n" || doitagain == "N")
{
moreEmp = false;
}
else
{
Console.WriteLine("You have entered an invalid information");
}
}
while (moreEmp == true);
所以我实际上用我的 if 语句分配了 bool 变量,我仍然不知道为什么我会犯这样的错误。感谢您阅读我的问题,希望您能帮助我:D。