Use continue to Jump to Next Iteration of While Loop

Within a while loop, you can use the continue statement to stop executing the current iteration of the loop and continue with the next iteration.


1
2
3
4
5
6
7
8
9
10
11
while (booksIWantToRead > 0)
{
    SelectNextBook();
    BuyNextBook();
    bool seemsInteresting = ReadBackCover();
    if (!seemsInteresting)
        continue;    // continue with next book
    ReadTheBook();
    TellFriendsAboutBook();
    booksIWantToRead--;
}