C# Decision Statements

C# Code Snippets Decision Statements


In this code snippet, we will learn how to use the if, else if and switch decision statements in C#.

The if decision statement will evaluate the expression provided in the brackets. If the expression is true the first code block executes else the other code block executes.

The switch statement is useful when you have a lot of checks to perform. You pass the value to be compared into the switch statement. Then you can write multiple cases for different possible values. 

Now let’s see how to do it in the code below.


[amp-gist id=”7544aaf17c5476f2e662000b0a7e51ae”]

Resulting output:


Leave a Reply

Your email address will not be published. Required fields are marked *

The reCAPTCHA verification period has expired. Please reload the page.
The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger