In this article I am going to discuss about the C# Control Flow Statements and its types but before that if you had not read my previous article of C# Operators then must read it for clear understanding. C# Control flow statements are constructs that enable you to manage the order of execution in a program. They allow you to make decisions, iterate over code blocks, and control the flow of the program based on conditions.

Introduction to C# Control Flow Statements

In C# , Control Flow Statements are the statements that Alter the Flow of Program Execution and provide better control to the programmer on the flow of execution. The Control Flow Statements are very beneficial to make better and complex programs. A program executes from top to bottom except when we use control statements. With C# Control Flow Statements we can control the order of execution of the program, based on logic, values and on any particular condition. Control Flow Statements are the divided into three types on the basis of usage.

Types of Control Flow Statements in C#

Control Flow Statements are divided into three types which is discussed below:

  • Selection Statements
  • Interation Statements
  • Jump Statements
C# Control Flow Statements

Selection Statements

In C#, a selection statement is a programming construct that allows the execution of different blocks of code based on the evaluation of a condition. The two primary selection statements in C# are the if else statement and the switch statement. But primarily Selection Statements are of three types which is discussed below :

  • If-Else Statement
  • If Else-If Statement
  • Switch Statement

Iteration Statements

In C#, iteration statements, also known as loops, are programming constructs that allow a block of code to be executed repeatedly as long as a specified condition is true. These statements enable developers to create efficient and readable code for tasks that require repeated execution, such as iterating over elements in an array.

  • For Loop
  • While Loop
  • Do-While Loop
  • Foreach Loop

Jump Statements

In C#, jump statements are constructs that allow you to alter the flow of control in a program by transferring the execution to a different part of the code. Jump Statements are also important when we have to come out of loop after certain period of time or if this condition is true. There are basically four types of Jump statements are there which is discussed below but instead of these one more jump statement is there which is used with throw keyword. But we use this keyword with exception handling so don’t worry.

  • Break Statement
  • Continue Statement
  • Goto Statement
  • Return Statement

Conclusion

In this C# tutorial article I have only given the brief introduction about the Control Statement and the various types of Control Statements. In our next articles we are going to discuss all the sub-types of control statements in very detail with examples so it will clear to you because these are very important as per programming point of you. Therefore you must have to understand all of the types very carefully so you will be able to know the use cases of above statements.