質問

for (i = 0; i < 14; i++)
{
     //display data here
}

Console.WriteLine("{0}", i);
Console.ReadLine();

I want to display the amount of times total i iterated outside the for statement so it only displays ONCE.

役に立ちましたか?

解決

Just add an i declaration before your for loop:

int i;
for (i = 0; i < 14; i++)
{
     //display data here
}

Console.WriteLine("{0}", i);
Console.ReadLine();

他のヒント

You can do:

int i = 0;
for(;i < 50; i++)
{
    // Do some stuff
}
Console.WriteLine(i.ToString());

Hope this helps!

You need to declare i outside the for loop.

define variable i before the loop and initialize it to 0;

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top