Category: Flow Control

Flow Control

Type Conversion

Type Conversion

The meaning of the variable is determined by the way in which this data is interpreted. The simplest example of this is the char type. This type represents a character in the Unicode character...

Infinite Loops C#

Infinite Loops C#

infinite loops are the loops which are executed endlessly. They are often useful sometimes where we don’t know out terminating condition at initial but later some terminating condition is known and loop may exit....

Continue statement C#

Continue statement C#

Continue only break the flow of the loop, not the whole loop. whenever continue encounters, loop body after continue will not be executed but the loop will continue as usual. Example

for Loop in C#

for Loop in C#

The last type of loop to look at in this tutorial is the for loop. This type of loop executes a set number of times and maintains its own counter. To define a for...

while Loop in C#

while Loop in C#

while loops are very similar to do loops, but they have one important difference: The Boolean test in a while loop takes place at the start of the loop cycle, not the end. If...

Do-While in C#

Do-While in C#

do loops operate as follows. The code you have marked out for looping is executed, a Boolean test is performed, and the code executes again if this test evaluates to true , and so...

Switch Statement in C#

Switch Statement in C#

The switch statement is similar to the if statement in that it executes code conditionally based on the value of a test. However, switch enables you to test for multiple values of a test...

Nested If Else

Nested If Else

In the preceding example, you checked for three conditions involving the value of var1 . This covered all possible values for this variable. Sometimes, you might want to check for specific values — for...

The if Statement c#

The if Statement c#

The if statement is a far more versatile and useful way to make decisions. Unlike ?: statements, if statements don ’ t have a result (so you can ’ t use them in assignments);...

The Ternary Operator

The Ternary Operator

The simplest way to perform a comparison is to use the ternary (or conditional ) operator mentioned in the previous tutorials. You ’ ve already seen unary operators that work on one operand, and...

The goto Statement

The goto Statement

C# enables you to label lines of code and then jump straight to them using the goto statement. This has its benefits and problems. The main benefit is that it ’ s a simple...

Boolean Logic

Boolean Logic

The bool type introduced in the previous tutorials can hold one of only two values: true or false . This type is often used to record the result of some operation, so that you...