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

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.