Search This Blog

Wednesday, October 17, 2012

How to exit for C#

C# > Statements > break

How to exit for C#? The answer is break.
The break statement terminates the closest enclosing loop or switch statement in which it appears. Control is passed to the statement that follows the terminated statement.

Example:

for (int j = 0; j < list.Count; j++)
{
    if (j==5)
       break;
}