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 trialJ o
1,281 PointsWhy doesn't my code work, 'int' does contain a definition for 'parse', what does this mean?
I don't understand why this error has occurred I've googled it, but the only thing that I found relating to the issue was that it may have to do with data types in which I don't see any issue!
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
//Prompts user to enter number of times it want the computer to say yay
Console.Write("Enter the number of times to print \"Yay!\": ");
//Variables to be used
string number;
int count;
//Takes the number that the user entered
number = Console.ReadLine();
//Change the entered value into an int
count = int.parse(number);
//Print yay to the screen the specified number of times
while(count>0){
Console.Write("Yay!");
count = count -1;
}
}
}
}
4 Answers
Sam Baines
4,315 PointsHi Jeremiah - I think its because the you have a slight typo for the Parse task. Also you can simplify code like follows:
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
static void Main()
{
//Prompts user to enter number of times it want the computer to say yay
Console.Write("Enter the number of times to print \"Yay!\": ");
//Variables to be used
int count = int.Parse(Console.ReadLine()); //Make sure you use a Capital 'P' for Parse
//Also sometimes you can use int32.Parse instead too
//Print yay to the screen the specified number of times
while(count>0){
Console.Write("Yay!");
count = count -1;
}
}
}
}
Hope this helps.
J o
1,281 PointsWow Silly mistake, Thank you Sam & Alexandre!
Alexandre C.
1,245 PointsYup, the only problem is the lowcase 'p' for Parse. Try it in capitals.
Alexandre C.
1,245 PointsNo that silly... I think it's very common to forget the way to write code, luckely Visual Studio auto-correct our code in real time, at least for noobs like us ;)
What I personally do is to re-read the code slowly before I run it. Because I am still learning that's useful to better understand the code, and to avoid this kind of mistakes.
Keep on with the good work!