How to use break statement to exit a for statement

using System;   public class ExitBreakFor { public static void Main( string[] args ) { int count; // control variable also used after loop terminates   for ( count = 1; count <= 10; count++ ) // loop 10 times { if ( count == 5 ) // if count is 5, break; // terminate […]
Continue reading…

Enjoyed this post? Share it!

 
 

Do While in C#

using System;   public class DoWhileExample { public static void Main( string[] args ) { int counter = 1; // initialize counter   do { Console.Write( "{0} ", counter ); ++counter; } while ( counter <= 10 ); // end do…while   Console.WriteLine(); // outputs a newline } // end Main } // end class […]
Continue reading…

Enjoyed this post? Share it!

 
 

Flow control in C# : Part 1 – Conditional statements IF-ELSE

The if-else statement is inherited from C and C++. The if-else statement is also known as a conditional statement. The ‘if’ statement block is executed when the condition is true; if it’s false, control goes to the else statement block. You can have a nested if-else statement with one of more else blocks. You can […]
Continue reading…

Enjoyed this post? Share it!