/*
Mastering Visual C# .NET
by Jason Price, Mike Gunderloy
Publisher: Sybex;
ISBN: 0782129110
*/
/*
Example4_13.cs illustrates the use of
the break statement
*/
public class Example4_13
{
public static void Main()
{
int total = 0;
for (int counter = 1; counter <= 10; counter++)
{
System.Console.WriteLine("counter = " + counter);
total += counter;
if (counter == 5)
{
System.Console.WriteLine("break from loop");
break;
}
}
System.Console.WriteLine("total = " + total);
}
}
|