For i = 0 To 10 Step 2
Debug.Print i
Next
Is there an equivalent for C# what does that look like? If there is no
equivalent would I have to do something like this (for the same
example):
for (int i = 0; i < 5; i++)
Console.WriteLine(i * 2)
Rich
*** Sent via Developersdex http://www.developersdex.com ***
i++ increments i by 1, so I think you can do this:
for (int i = 0; i < 11; i += 2)
{
Console.WriteLine(i);
}
Karl
http://unlockpowershell.wordpress.com/
for(int i = 0; i < 5; i +=2) /
Console.WriteLine(i)
mick
---
frmsrcurl: http://msgroups.net/microsoft.public.dotnet.languages.csharp/increment-for-loop-by-step-2-in-C
> for (int i = 0; i < 5; i++)
> Console.WriteLine(i * 2)
>
I see you already have the answer, but wanted to share.I saw this in a
program I was fixing recently:
for (int i = 0; i < x.Count; i++)
{
//Do work
i++;
}
Hoepfully that gives someone a Christmas smile.
Peace and Grace,
--
Gregory A. Beamer (MVP)
Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com
*******************************************
| Think outside the box! |
*******************************************
More like wondering where my axe is ...
:-)
Arne