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) Perfect Final

Deborah Reyes
Deborah Reyes
563 Points

Compilation Failed; C# Basics Final

I keep getting this error: Program.cs(7,19): error CS1525: Unexpected symbol `)' Compilation failed: 1 error(s), 0 warnings

I'm not too sure what it's talking about because line 7 is "static void Main ()". Could anyone help me?

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main ()
        {
            while ()
            {
                Console.Write("Enter the number of times to print \"Yay!\": ");
                var entry = Console.ReadLine();

                try
                {
                    var numTimes = int.Parse(entry);
                    if (numTimes <=1)
                    {
                        Console.WriteLine("You must enter a positive number.");
                    }
                    while (numTimes > 0)
                    {
                        Console.WriteLine("Yay!");
                        numTimes--;
                    }
                }

                catch (FormatException)
                {
                    Console.WriteLine("You must enter a whole number.");
                }
            }
        }
    }
}

2 Answers

Jon Wood
Jon Wood
9,884 Points

A boolean expression in the while is empty, which is causing the compilation error.

Not sure why the compiler is complaining about line 7, but the while() is wrong. You have to have something inside the (). For example, while(true) would work.