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# C# Basics (Retired) Console I/O Formatting Output

Declare a variable named firstName and initialize it to the string returned from a call to Console.ReadLine().

I don't really understand it, this is what I have so far...

{ Console.ReadLine ("firstName");

string firstName = ("Daniel");

}

CodeChallenge.cs
{
    Console.ReadLine ("firstName");

    string firstName = ("Daniel");
}

2 Answers

Dale Severude
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Dale Severude
Full Stack JavaScript Techdegree Graduate 71,350 Points

Hey Daniel,

You don't need to put any parameters within the ReadLine() statement. Just assign your variable to be equal to the value that the ReadLine() returns.

var firstName = Console.ReadLine();
Todd Anderson
Todd Anderson
4,260 Points

Hi!

It's asking you to assign the input from Console.ReadLine() to the variable firstName as a string like so.

string firstName = Console.ReadLine();

This means whatever is typed in by the user whether it's Daniel or Todd, etc, it will be saved as the variable you initialized as firstName.

Also, since firstName is a variable name, you would call it in parentheses as (firstName) not ("firstName"). Doing so with quotes would actually treat the word firstName as a string instead of calling the variable. I hope this helps!

Spoiler: Answer below...

string firstName = Console.ReadLine();
Console.WriteLine(firstName + " rocks!");