Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Jonathan Morton
7,942 PointsC# 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.");}
}
}
}
1 Answer

Steven Parker
215,984 PointsI 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.
Steven Parker
215,984 PointsSteven Parker
215,984 PointsTo make posted code readable, use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area.
Or watch this video on code formatting.