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#

Hello Guys, does someone know what the function ,,System.Console.ReadLine'' does?

What does the function System.Console.ReadLine(); do?

I have an example:

I build a fitness app, and the app asks you how many times you exercise, then we use System.Conole.Write(''How many minutes did you exercise'') and in order that user can answer the question, we have to use the function ,,System.Console.ReadLine(); and store it to a variable. Is that right? Why do we need this funktion?

1 Answer

Steven Parker
Steven Parker
231,248 Points

System.Console.ReadLine is the function that gets a line of characters that the user typed and returns it as a string. You said it yourself, you need this so the user can answer your question.

The MSDN Documentation is a good source of information for things like this.