Sponsored Ad

Friday, September 25, 2009

The for Loop in C#

The for loop is so similar to c/c++ for loop. The for loop is accomplished for repeating a account or a block of statements for a specific number of times.
for loop contains the starting point that is i=0, we can have any starting point as per our requirement.
second part is condition, when for loop will break.
third one is increment, what increment should program follow.


Example:
using System; class ForLoop {     public static void Main()     {         for (int i=0; i < 20; i++)         {             if (i == 10) break;             if (i % 2 == 0)                 continue;             Console.Write("{0} ", i);         }         Console.WriteLine();     } }

0 comments:

Post a Comment

Sponsored Ad

Website Update

Followers