In C#, various types of decision making statements are available such as if..else, if..else..if, switch etc. Each statement is used to evaluate the specific test. If tests are determined to be true, specific statement will be execued for example : if(a > b) statement1 else statement2. Sometimes when develpoing program that requires to take the decision to execute specific part of program, decision making statement helps to do so.
Sometimes we reqiure to execute certain statement when specified condition true.
Syntax
When specified condition fail the else statement will get execute.
Syntax
When there are situations when we need to test several conditions then we will use else if condition.
Syntax
In C# switch acts like a multiple if / else if / else chain. Checks a value against a list of cases, and executes the first case that is true. If no matching case found, it executes the default case. The break(optional) statements with case indicate to the interpreter to end the particular case.
Syntax
If forget a break which is optional than code will run from the case where condition is met, and will run the case after that regardless if condition was met.