1. C# uses the if/else statement to make decisions. An else clause is
optional and specifies the action to be taken if the condition evaluates false.
If there are multiple statements for the if or else, the statements must be
enclosed in braces.
2. UML activity diagrams can help visualize the logic of an if/else statement.
3. The conditions for an if statement are evaluated for true or false.
4. Conditions can be composed of the relational operators, which compare
items for equality, greater than, or less than. The comparison of numeric
values is based on the quantity of the number, while character comparisons
are based on the ANSI code table. Strings may use the equal and not equal
operators or the string methods Equals and CompareTo.
5. The ToUpper and ToLower methods of the String class can convert a text
value to upper- or lowercase.
6. The &&, ||, &, and | logical operators may be used to combine multiple
conditions. With the && operator, both conditions must be true for the en-
tire condition to evaluate true. For the || operator, if either or both condi-
tions are true, the entire condition evaluates as true. When both && and ||
are used in a compound condition, the && condition is evaluated before the
|| condition. || and && short circuit the condition so that the second part
of a compound condition may not be tested; use a single symbol—| or &—
to not short circuit and thus force evaluation of all conditions.
7. A nested if statement contains an if statement within either the true or
false actions of a previous if statement. An else clause always applies to
the last unmatched if regardless of indentation.
8. The state of radio buttons and check boxes is better tested with if state-
ments in the event handler for a button, rather than coding event handlers
for the radio button or check box. Use individual if statements for check
boxes and nested if statements for radio buttons.
9. The MessageBox.Show method can display a multiline message if you con-
catenate a New Line character (\n) to specify a line break.
10. You can choose to display multiple buttons in a message box. The
MessageBox.Show method returns an object of the DialogResult class,
which you can check using the DialogResult constants.
11. Data validation checks the reasonableness or appropriateness of the value
in a variable or property.
12. You can assign the event-handling method to a control in the Properties
window. The same method can be assigned to multiple controls, so that the
controls share the event handler.
13. You can use the sender argument in an event-handling method to deter-
mine which control caused the method to execute.
14. One method can call another method. To call an event-handling method,
you must supply the sender and e arguments.
15. A variety of debugging tools are available in Visual Studio. These include
writing to the Output window, breaking program execution, displaying the
current contents of variables, and stepping through code.
To learn more about the book this website supports, please visit its Information Center.