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 trialTomasz Necek
Courses Plus Student 7,028 PointsC# Print word number of times depending on the input value
Can you help me.. How can I fix it?
Program.cs(10,14): error CS1519: Unexpected symbol for' in class, struct, or interface member declaration
Program.cs(10,29): error CS1519: Unexpected symbol
<' in class, struct, or interface member declaration
Program.cs(10,37): error CS1519: Unexpected symbol ;' in class, struct, or interface member declaration
Program.cs(10,41): error CS1519: Unexpected symbol
++' in class, struct, or interface member declaration
Program.cs(11,12): error CS9010: Primary constructor body is not allowed
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
Console.Write("Enter the number of times to print \"Yay!\": ");
int number = Int32.Parse(Console.ReadLine());
}
for(int i = 0; i < number; i++)
{
Console.WriteLine("word!");
}
}
}
1 Answer
Justin Horner
Treehouse Guest TeacherHello Tomasz,
You're receiving that error becuse you have the for loop outside of the Main function block. Also, make sure you change your WriteLine method to print "Yay!" instead of "word!" to pass the challenge.
I hope this helps. If you have any other questions please let me know.