![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 );