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 trialKevin Gent
1,028 PointsC# Basics: Final Challenge 2 of 3 continue statement problem
error CS0139 Something is wrong with my continue statement. To my limited knowledge my continue statement should be putting me back to the top of my code where it asks the user to enter the number of "Yays!". What am I doing wrong with my continue statement?
1 Answer
Kevin Gent
1,028 PointsOoop found it out. continue statments go back to loops. All I had to do was add another while and put it on the outside of everything. Here is my finalized code that works:
while (true)
{
Console.Write("Enter the number of times to print \"Yay!\": ");
try
{
int counter = 0;
String times = Console.ReadLine();
int totals = int.Parse(times);
while (counter < totals)
{
Console.Write("\"Yay!\"! ");
counter += 1;
}
}
catch
{
Console.WriteLine("You must enter a whole number");
continue;
}
Kevin Gent
1,028 PointsKevin Gent
1,028 PointsIs it not showing my code? I checked the include code box? Well if not seen here is my code: