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#

What does Console.WriteLine(Console.ReadLine)); do?

This is from the Console I/O video by Carling Kirk, as part of the C# Streams and Data Processing course.

I Do not understand why the ReadLine method is passed in as an argument into the WriteLine method.

Thanks

2 Answers

Izzatilla Karimov
Izzatilla Karimov
9,284 Points

You must've got it wrong because Console.WriteLine( Will Print Out A String or the value u pit in it ) Console.ReadLine(); Will Read the line that u enter.. Example: Console.Write("Enter a number: "); Console.ReadLine(); //this will read the number that user put in var num = Console.ReadLine(); //or you can store in a variable then place the variable in the WriteLine as an argument...

Hi,

Thanks for your reply. If you check out that video, it uses that. That's why I am confused, as I don;t know what it does.

THanks

Izzatilla Karimov
Izzatilla Karimov
9,284 Points

Oh yeah, I went back to that course and i saw that i did not finish that objective...xD I watched the video again, and the objective is asking you to create string, string bookTitle; then the next step is asking to put value string bookTitle = "title of favorite book"; like this. thank for telling me to go back otherwise I wouldn't have done that objective myself xDD!