< C Sharp for Beginners
If Statement:
The if statement in c# is so simple like other languages. The syntax for if statement is:
if(condition){
// Statements
}
Here is condition we can check some expression for true or false. For example 5 > 4 is true but 4 > 5 is false.
if(5 > 4){
Console.WriteLine("Yes five is still greater than 4");
}
Else part:
In the else part if if condition we can give statements which will execute if condition is false.
if(5 > 4){
Console.WriteLine("Yes five is still greater than four");
} else {
Console.WriteLine("Oh No! five is now no longer greater than four");
}
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.