Beruflich Dokumente
Kultur Dokumente
1 Program Output
2
3
4
5
Determine if final
value of control true Console.WriteLine
counter <= 10 counter++
variable has been ( counter * 10 );
reached.
Increment the
false Body of loop (this may be control variable.
multiple statements)
1 Program Output
2
3
4
5
• Increment/Decrement
– When incrementing
• In most cases < or <= is used
– When decrementing
• In most cases > or >= is used
• Message boxes
– Buttons
• OK
• OKCancel
• YesNo
• AbortRetryIgnore
• YesNoCancel
• RetryCancel
• Massages boxes
– Icons
• Exclamation
• Question
• Error
• Information
• Formatting
– (variable : format)
• Table 5.9 lists some formatting codes
Argument 4:
MessageBox Icon Program Output
(Optional) Argument 2: Title bar
string (Optional)
MessageBoxButton.RetryCancel Specifies that the dialog should contain Retry and Cancel
buttons. Typically used to inform a user about a failed
operation and allow the user to retry or cancel the operation.
MessageBoxButton.AbortRetryIgnore Specifies that the dialog should contain Abort, Retry and
Ignore buttons. Typically used to inform the user that one
of a series of operations has failed and allow the user to
abort the series of operations, retry the failed operation or
ignore the failed operation and continue.
Interest.cs
Program Output
F or f Formats the string with a fixed number of decimal places (two by default).
G or g General. Either E or F.
X or x Formats the string as hexadecimal.
Fig. 5.9 string form a tting c od es.
true
case: a case a action(s) break;
false
true
case: b case b action(s) break;
false
.
.
.
true
case: z case z action(s) break;
false
default action(s)
break;
1
2 Program Output
3
4
5
action(s)
true
condition
false
• Use
– Used to alter the flow of control
– The break statement
• Used to exit a loop early
– The continue statement
• Used to skip the rest of the statements and begin the loop at the
first statement in the loop
– Programs can be completed without their usage
BreakTest.cs
Program Output
ContinueTest.cs
Program Output
• Operators
– Logical AND (&)
– Conditional AND (&&)
– Logical OR (|)
– Conditional OR (||)
– Logical exclusive OR or XOR (^)
– Logical NOT (!)
• Can be avoided if desired by using other conditional operators
• Used to add multiple conditions to a statement
Conditional OR (||)
false || false: False
false || true: True
true || false: True
true || true: True
2001 Prentice Hall, Inc.
All rights reserved.
34
Logical AND (&) Outline
false & false: False
false & true: False
true & false: False
true & true: True LogicalOperators.cs
Program Output
Logical OR (|)
false | false: False
false | true: True
true | false: True
true | true: True
• Control Structures
– Only one entrance
– Only one exit
– Building blocks to programming
– Allow nesting
– Makes code neater and easier to follow
– No overlapping structures
• The goto keyword
.
.
Fig. 5.22 C#’s single-entry/single-exit sequence, selection and repetition structures. (part 1)
F
break
Fig. 5.22 C#’s single-entry/single-exit sequence, selection and repetition structures. (part 2)
do/while structure F
Fig. 5.22 C#’s single-entry/single-exit sequence, selection and repetition structures. (part 3)
.
.
.
Fig. 5.25 Repeatedly applying rule 2 of Fig. 5.23 to the simplest flowchart.
Rule 3
Rule 3