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 trial

C#

Paul Rowe
Paul Rowe
1,516 Points

Console doesn't wait for input from Console.ReadLine();

From C# Basics...

The following code:

[...]
  Console.Write("Enter how many minutes you exercised: ");
  string entry = Console.ReadLine();
[...]

does not wait for an input from the user in the console. Instead, the console renders like this:

treehouse:~/workspace$ mcs Program.cs && mono Program.exe                                                                                          
Enter how many minutes you exercised: treehouse:~/workspace$ 30                                                                                    

and then when entering the value 30, spits out

bash: 30: command not found

My code reflects exactly what is in the instructional videos, any help?

2 Answers

Paul Rowe
Paul Rowe
1,516 Points

Welp, didn't hit "Save" before compiling. I have autosave on unfocus in my local editor and I totally spaced that this doesn't exist in the Treehouse Workspace. Whoops (facepalm)

Steven Parker
Steven Parker
231,236 Points

The "command not found" is normal because the program had already ended.

So the "30" you typed was taken as a new command.

But it looks like your program is trying to read from a closed input stream. I'm not sure why it would be closed. This might be an issue to take up with the Support folks.