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# averager problem. Compiler says "possibly blank statement." Starting line 18. Not sure what I am doing wrong

namespace AverageCalc { class Program { static void Main() { var total=0.0; var totalNum=0.0; var average=0.0;
while(true) try { System.Console.Write("Please input any series of whole numbers and type done when finished. /n"); var entry = System.Console.ReadLine();
total += double.Parse(entry); totalNum += 1;
average=total/totalNum; if (entry.ToLower() == "done"); <line 18>{System.Console.Write("your average is" + average + ".");} } catch (System.FormatException) {System.Console.Write("That is not valid input. Please input a whole number.");}

  }  
}

}

Steven Parker
Steven Parker
229,657 Points

To make posted code readable, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down: Or watch this video on code formatting.

1 Answer

Steven Parker
Steven Parker
229,657 Points

I see two possible syntax issues.

I can't be sure without proper code formatting, but it looks like you have at least these two issues:

if (entry.ToLower() == "done");

A semicolon after an if statement ends it, so it effectively does nothing. In particular, it will not control the code block that follows.

<line 18>

This is not a comment, and it's also not C# code.