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 trialWei Li
5,860 PointsI entered "25" but nothing was printed out. Make sure to write the message to the console.
I entered "25" but nothing was printed out. Make sure to write the message to the console.
int value = int.Parse(Console.ReadLine());
try
{
if (value >0 && value <20)
{
Console.WriteLine(string.Format("You entered {0}",value));
}
}
catch(Exception)
{
Console.WriteLine("Value is out of bounds");
}
1 Answer
Steven Parker
231,198 PointsIt looks like you changed some of the original code.
For this challenge, you will only add to the original code. It's important to leave the original code lines intact. The throw statement you removed is critical to the proper function of your added try/catch blocks. And as Gregor pointed out, moving the value response statement changes the conditions where it would be displayed.
Otherwise, your code looks good except that the challenges are very particular about returned strings, so you need to leave the exclamation point in the string "Value is out of bounds!"
.
Gregor Ojstersek
17,618 PointsGregor Ojstersek
17,618 PointsHey,
The if statement value is false, because 25 is larger than 0, but also larger than 20. Make it like: value < 30 and it will log "You entered 25" to the console.