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

Andre Battle
Andre Battle
192 Points

I think the way the question is presenting itself is whats confusing me?

string firstName;

Console.ReadLine();

Console.WriteLine(string firstName)

Did I do something wrong?

CodeChallenge.cs
string firstName;

Console.WriteLine(string firstName)

Console.ReadLine();

3 Answers

Antonio De Rose
Antonio De Rose
20,885 Points
string firstName;// you've been asked to store, whatever been entered in from the prompt, for readLine

Console.WriteLine(string firstName)//when you print inside paranthesis, you need not have the variable type

Console.ReadLine();// this should go at the very first step, taking this as an input, and store into the firstName var

In short: just remove the String declaration in the Console.WriteLine() method call, and finish the sentence with ;

string firstName; Console.WriteLine(firstName); Console.ReadLine();

by writing the variable type String before the name of the variable, yo are declaring it.

1st: You have already declared in the previos line: string firstName;

2nd the method Console.WriteLine() takes a String parameter that needs to already be declared.

See MSDN reference for Console.WriteLine() method: https://msdn.microsoft.com/library/xf2k8ftb(v=vs.110).aspx

Christopher Pritchard
Christopher Pritchard
3,411 Points

Hi Andre,

Try the following:

    //Assign firstName the information that is read from ReadLine
    string firstName = Console.ReadLine();

    //Write it out. Don't forget the semicolon (;) at the end.
    //You already declared it as a string. From now on just use its name.
    Console.WriteLine(firstName);