Wednesday, 13 April 2016

C# For Beginners Lesson 12 If Selection Statement


JScript supports if and if...else conditional statements. An if statement tests a condition. It executes the relevant JScript code if the condition evaluates as true. An if...else statement tests a condition and executes one of two blocks of code depending on the result of the condition statement. The simplest form of an if statement can be written on one line, but multiline if and if...else statements are more common.

Conditional Statement Examples

The following examples demonstrate syntaxes you can use with if and if...else statements. The first example shows the simplest kind of Boolean test. If (and only if) the item between the parentheses evaluates to (or can be coerced to) true, the statement or block of statements after the if is executed.
In the following example, the registerUser function is called if the value of newUser converts to true.
if (newUser)
   registerUser();
In this example, the test fails unless both conditions are true.

No comments:

Post a Comment