Mega Code Archive

 
Categories / C# Tutorial / Statement
 

The if Statement

You can selectively execute part of a program through the if statement. Its simplest form is shown here: if(condition)     statement; condition is a Boolean (that is, true or false) expression. If condition is true, then the statement is executed. If condition is false, then the statement is bypassed. The complete form of the if statement is if(condition)     statement;  else     statement; The general form of the if using blocks of statements is if(condition) {     statement sequence  } else {     statement sequence  } if-else-if ladder. It looks like this: if(condition)    statement;  else if(condition)    statement;  else if(condition)    statement;  . else    statement;