C# if statement1 min read

An if statement consists of a Boolean expression followed by a block of codes. If the Boolean expression is true, the block of code inside the if statement will be executed else if statement will be skipped. This is the simplest one of all the decision-making statements.

The syntax of the if statement in C#:

Note: If the curly brackets { } are not used with the if statement then the statement just next to it will only be executed and others will not be considered as a part of the statement.


if statement Flowchart:

if statement

Example of C# if statement:

Output:


MORE

Keith Number Program in C

In this tutorial, we will write a Keith number in C. It is one of the most asked questions in an interview. Before that, you …
Read More

Keith Number Program in C++

In this tutorial, we will write a Keith number in C++. It is one of the most asked questions in an interview. Before that, you …
Read More

Singly linked list Program C++

In this tutorial, we will write a C++ program to implement singly linked list. In this program, we will create a separate function for each …
Read More

Fascinating Number Program in C

In this tutorial, we will write a C program to check whether the given number is a Fascinating number or not. You may go through …
Read More

Peterson Number in C

In this tutorial, we will learn about the Peterson number and check if the number is Peterson or not in C. What is Peterson Number? …
Read More

Peterson Number in C++

In this tutorial, we will learn about the Peterson number and write a C++ program to check if the given number is a Peterson number …
Read More