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.

Austin Marcoux
835 PointsUnexpected symbol "{"
I get 2 error messages saying the compiler didn't expect "{", one on line 8 and the other on line 14. There is equally as many "{" as "}". Also, I am not getting any other error messages. Please help...
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Try
{
Console.Write("Enter the number of times to print \"Yay!\": ");
var entry = Console.ReadLine();
var k = int.parse(entry);
}
Catch(FormatException)
{
Console.WriteLine("This is an invalid input");
}
while (counter > 0)
{
Console.WriteLine("Yay!");
counter = counter - 1;
}
}
}
}
2 Answers

emmuster
1,533 PointsIt is because you have some typos in your code, remember that C# is a capitalization sensitive language:
Try should be try
Catch should be catch
int.parse should be int.Parse
Your while loop is also not functioning, but that is a different problem you should be a able to fix yourself.

Carlos Ramirez
5,084 PointsTry putting a semicolon after the catch clause:
Catch(FormatException)
{
Console.WriteLine("This is an invalid input");
};