
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
What are control statements in C#?
The flow of program control is specified by control statements in C#. It includes the following −
if statement
An if statement consists of a boolean expression followed by one or more statements.
The following is the syntax −
if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ }
if-else statement
An if statement can be followed by an optional else statement, which executes when the boolean expression is false.
The following is the syntax −
if(boolean_expression) { /* statement(s) will execute if the boolean expression is true */ } else { /* statement(s) will execute if the boolean expression is false */ }
for loop
It executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
The following is the syntax −
for ( init; condition; increment ) { statement(s); }
while loop
It repeats a statement or a group of statements while a given condition is true. It tests the condition before executing the loop body.
The following is the syntax −
while(condition) { statement(s); }
do…while loop
It is similar to a while statement, except that it tests the condition at the end of the loop body.
The following is the syntax −
do { statement(s); } while( condition );
- Related Articles
- What is Control Statements?
- Loop Control Statements in Python
- Loop Control Statements in Perl
- What is translation of control statements in compiler design?
- What are the loop control statements in C language? Explain with flow chart and program
- What is Backpatching of Boolean Expressions and Control Statements in compiler design?
- What are Control dependencies?
- What are Program Control Instructions?
- What are label statements in JavaScript?
- What are provision in financial statements?
- What are reserves in financial statements?
- Loops and Control Statements (continue, break and pass) in Python
- What are Logical Link Control (LLC) and Medium Access Control(MAC)?
- How to define control flow statements in JShell in Java 9?
- What are decision making statements in C#?
