case 3: // Record Daily Activity
for (iOption = 3; iDayNum++;)
Console.WriteLine("Record a Daily Activity"); //Lets the user know which option they selected.
我希望程序每次选择选项3时计算一天,但我收到以下错误:
Cannot implicitly convert type 'int' to 'bool'
Use of unassigned local variable 'iDayNum'
答案 0 :(得分:2)
由于问题缺乏背景,我假设在这里有一些东西。简单的增量怎么样?
//Initialization somewhere...
int iDayNum = 0;
switch(iOption)
{
case 3:
iDayNum++;
Console.WriteLine("Record a Daily Activity");
Break;
default:
Break;
}