tumblr tracker

If

Parent Previous Next

If keyword


Checks whether a certain condition is true and only then executes associated commands.


If (condition is true) {

//commands to execute

}


The brackets () enclosing the condition and the curly brackets {} enclosing the commands to execute are required. The curly bracket can also start on a line of its own.



Example


$now = DateTime.GetCurrentDateTime();
$month = DateTime.GetMonth($now);

If ($month > 3 and $month <= 6)
{
   MessageBox.ShowInfo("We are in the second quartal of the year.");
}