Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialJun Dong
4,754 PointsWhat does continue; do
while(true)
{
continue;
Console.WriteLine("Ribbit")
}
Console.WriteLine("Croak");
This is one of the quiz questions i don't understand why this code doesn't print anything
1 Answer
cbekter
7,600 PointsContinue allows you to control the flow of your loop by skipping the current iteration and returning back to the beginning of the loop. In your example, when you get into the loop, you are immediately taken out of it because of continue, however, because true is still "true", you are in an infinite loop that just keeps taking you out the iteration and starting back at the beginning. If something were to, for example, change the true value to false, it would go back to the beginning of loop, see that true is now false and be able to print out "Croak".
bool example = true;
while (example)
{
example = false;
continue;
Console.WriteLine("Ribbit");
}
Console.WriteLine("Croak");