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 trialBryan Sory
1,978 PointsFinal code challenge in Basic C# won't compile. Suspect that it's my use of Int32.Parse. Any suggestions?
I tried a function I found in Stack called Int32.Parse but that isn't compiling.
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("Yay!")
}
}
}
1 Answer
Alexander Davison
65,469 PointsYou did a great job researching! Most students probably won't do that but as a programmer you should be researching a lot. But, you forgot to use curly braces for the for loop! Try this:
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("Yay!");
}
}
}
}
Hope this helps! ~Alex
Bryan Sory
1,978 PointsBryan Sory
1,978 PointsThat did the trick. Much obliged.
Alexander Davison
65,469 PointsAlexander Davison
65,469 PointsNo problem :)