- INDEX (start here)
References: loops: View the Microsoft information on loops in C#
Prepare code for loop: Statements to add 1,2,3 to list box individually are converted to a while loop.
A few notes about the while loop: Cautions about possibility of endless loops and loops that execute 0 times.
Sorted values: If the sorted property of the list box is true, the values are sorted as strings
While, cont.: A while loop generates the powers of 2: 2, 4, 8, 16, 32, 64, 128, 512, 1024
Position of increment in loop: The position of the increment changes the values and also what is added to list box
Introducing the for loop: The while loop to add 1, 2, 3 to the listbox is changed to a for loop.
Introducing the for loop: The while loop to add 1, 2, 3 to the listbox is changed to a for loop.
Format of the for Loop: Explanation of the format of the for loop.
Compare while and for Loops: Compares a for and a while loop that each generate the values 1, 2, 3, 4, 5.
Compare while and for Loops: Compares a for and a while loop that each generate the values 1, 2, 3, 4, 5.
Introduction to do Loops: A do loop always executes at least once.
Introduction to do Loops: A do loop always executes at least once.
do loops test condition at end, and execute 1 or more times : A do loop tests the condition at the end of the loop.
Endless do loops: Shows a do loop that is endless because there is no increment of the variable.
Endless do loops: Shows a do loop that is endless because there is no increment of the variable.
Compare for, while, and do Loops: Each of the loops puts the numbers from 1 to 10 in a list box.
Compare for, while, and do Loops: Each of the loops puts the numbers from 1 to 10 in a list box.
Months and Seasons: The switch/case block is embedded inside the loop
Months and Seasons: The switch/case block is embedded inside the loop
Nested Loops: One loop can be inside another loop, or nested
Nested Loops: One loop can be inside another loop, or nested
Nested Loops: generate a deck of cards: A loop for each suit with a nested loop for each card.
Also uses switch.
For Each Loops: The foreach loop works on a collection or an array.
For Each Loops: The foreach loop works on a collection or an array.
For Each Loops with a List: Use the foreach loop to remove blank lines from a list box.
For Each Loops with a List: Use the foreach loop to remove blank lines from a list box.