Monday, April 7, 2008

Breaking out a loop in two ways

The two ways described below.
1) firstway is using "break" keyword
2) Second way is using variable declaration.

//First way
for (int i = 0; i < 5; i++)
{
Response.Write("bala");
break;
}
//Second Way
bool br = false;
for (int j = 0; j < 2&& br == false; j++)
{
Response.Write("testingbala");
br = true;
}