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

can you help me to format this problem

i dont know how to do any of these code challenges can you please just give me an example because every time i try it says im declaring the variable wrong

CodeChallenge.cs
string firstname;
Console.ReadLine(firstname)

1 Answer

Tsenko Aleksiev
Tsenko Aleksiev
3,819 Points

First you tell the computer what type your variable is, in your example is string ( text between quotes aka “Tsenko” ), than you name your variable, for example firstName and than you give your variable a value which you asign with the “=“ operator. So all is: string firstName = “Tsenko”; Using Console.ReadLine(firstName); you just tell the computer to print you what’s inside the firstName variable, so the result will be “Tsenko”. Got it? The variable is like a box you place something inside and name the box with a pencil. So when you write the name of the box, it shows what’s inside.