June 2006
Intermediate to advanced
1344 pages
42h 52m
English
A selection statement chooses among alternative courses of action. For example, suppose that the passing grade on an examination is 60 (out of 100). Then the statement
If studentGrade >= 60 Then Console.WriteLine ("Passed") End If
outputs the string "Passed" if the student’s grade is at least 60.
The preceding If...Then selection statement also could be written on a single line as
If studentGrade >= 60 Then Console.WriteLine("Passed"
In the multiple-line format, all statements (there can be many) in the body of the If...Then are executed if the condition is true. In the single-line format, only the statement immediately after the Then keyword is executed if the condition is true. Although writing the If ...
Read now
Unlock full access