Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

C# C# Basics (Retired) Console I/O Formatting Output

How to use Console.WriteLine to print contents of the variables

string entry = "firstName"; Console.Write("what is your first name "); Console.ReadLine(); Console.WriteLine("Muhaned");

CodeChallenge.cs
string entry = "firstName";
Console.Write("what is your first name ");
Console.ReadLine();
Console.WriteLine("Muhaned");

1 Answer

Audrey Steed
Audrey Steed
1,112 Points

Here is my code for that:

string entry; 
Console.Write("What is your name?:"); 
entry = Console.ReadLine(); 
Console.WriteLine(entry); 

Console.WriteLine(); Prints text to the screen and makes the next text on a new line.

Console.Write(); Same as Console.WriteLine(); but the next text will be on the same line.

Console.ReadLine(); Gets input from the user and returns it in a string value.