Monday, December 15, 2008

break Satement:

Definition:

This statement is often used in conjunction with switch statements; however, C# allows you to use it to break out of the current block of statements. The break statement is usually used to break out from an iteration statement block.

Example:


static void Main(string[] args)

{

int i = 0;

while (i !=5)

{

Console.WriteLine(i);

Console.ReadLine();

if (i == 2)

break;

i++;

}

}


Output:

0
1
2

No comments: