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 trialMichael North
2,561 PointsWhy doesn't this work?
I've been working on this for about an hour now, and I just don't understand it. The console is not recognizing >. Please Help
int value = int.Parse(Console.ReadLine());
if (value > 0 || <20)
{
throw Exception;
}
Console.WriteLine(string.Format("You entered {0}",value));
2 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Michael,
There are actually a few things going wrong here.
First, the conditional statement has a couple of errors:
- The second part of the conditional, after the
or
also needs the variable name it is checking against. The compiler doesn't understand if you just put>20
. It needs to be just like the first one. - What you are checking for is backwards. The challenge says to throw an exception if the value is outside of the defined range, but you are checking to see if it is inside the range. So, you need to check if it is less than zero or greater than twenty.
Next is how the Exception is being called. A System.Exception
needs to be called with the new
keyword and have opening and closing parenthesis to hold the error message. Although for this task, just leave it empty. So, you actually need to throw new System.Exception()
.
Give it another go with these in mind. You're almost there, and I'm sure you'll get it now.
Keep Coding! :)
Michael North
2,561 PointsThatnk you very much this helped a ton!