Introduction
The flow of program control using the given condition whether the condition is “TRUE” or “FALSE”. Some keyword are given below which are used for selection statements:
- If
- Else
- Switch
- Case
- Break
- Default
Here we will discuss if else statement.
Definition
The if statement runs when the condition is “TRUE”, while when the condition is “FALSE” the else statement runs.
Example
- if(statement==true) //condition true
- {
- //Execute this part.
- }
- else //condition false
- {
- //Execute this part.
- }
Simple Code
- static void Main(string[] args)
- {
- int a = 2; //initialization and declaration..
- int b = 3; //initialization and declaration..
- int c; //initialization..
- c = a + b; //doing sum of a & b and store in c..
- if (c == 5) //checking condition..
- {
- Console.Write("Condition True.."); //true condition code..
- }
- else //false statement
- {
- Console.Write("conditiion false.."); //false condition code..
- }
- Console.ReadKey();
- }


Afzaal Ahmad ZeeshanPosted Mar 22, 2015, 3:58 PM
Since you're not using the break structure it would be better to remove it. There is no need to write content that is not related to your post.