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 trial

C# C# Basics (Retired) Perform Looping

Am I missing something?

'''int counter = 0;

while(cycle == true) { counter = counter + 1; } Console.WriteLine(counter); '''

Shouldnt it skip the loop because it hasnt a boolean before the loop that says true? Im a bit confused

6 Answers

Hi,

Read again the question, it is said there that the value for cycle is true.

Yes, But they Never say that it is a boolean? I cant see it, to put ”cycle == True” in while you have to have a boolean right ?

They did not write that line of code but they told you that cycle was set to true. https://imgur.com/yHJ8YiP

So you dont need to have boolean above the loop?

bool cycle = true;

while(cycle == true) { Console.WriteLine("I'm cool."); }

Are you missing the "bool cycle = true"?

No I didnt miss the boolean, in that quiz question there wasnt a boolean. Idk why and Thats why I’m asking the community :)

Read my code above, Its on 1 line ( dont ask me why)

Hi there, you are correct in your assumption here that if you were actually writing code you would need to create a boolean variable named cycle for this code to run. I think that for the purposes of this quiz question they omit that from the code and tell you that it is true.

Ah thanks Michaelcodes.. I cant set your comment to best answer because it's an answer..