Current .Net Version: 1.1.4322
Home
Articles
Practice C# Online
C# Reference
XML Web Services
RSS Feeds
T-SQL Scripts
Valuable Links
Contact Us
C# Reference
List: Search:

if-else
Is a:Statement Keyword
Applies to Version:C# 1.0 and later
Namespace:N/A
Assembly:N/A (N/A)
Description:A statement that controls the execution a block of code if an expression evaluates to true. If the expression evalutes to true, the first statement is executed, otherwise, the second statement it executed.
Syntax:
if (expression)
   statement1
[else
   statement2]
Example(s):bool bln1 = false; if (bln) MessageBox.Show("It's TRUE!"); else MessageBox.Show("It's FALSE!"); if (bln == true) { MessageBox.Show("It's TRUE!"); } else MessageBox.Show("It's FALSE!"); if (bln == false) { MessageBox.Show("It's FALSE!"); } else { MessageBox.Show("It's TRUE!"); }
 
COPYRIGHT/DISCLAIMER | CONTACT US