如何使用此方法添加计数器?

时间:2015-11-27 10:20:59

标签: c#

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'

1 个答案:

答案 0 :(得分:2)

由于问题缺乏背景,我假设在这里有一些东西。简单的增量怎么样?

//Initialization somewhere...
int iDayNum = 0;

switch(iOption)
{
    case 3:
        iDayNum++;
        Console.WriteLine("Record a Daily Activity");
        Break;
    default:
        Break;
}