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

Abdul Majid Qureshi
Abdul Majid Qureshi
170 Points

declaring a string relates to is it a string ? or what? and should be = System.Console.Readline();

firstName= System.Console.ReadLine();

CodeChallenge.cs
 firstName= System.Console.ReadLine();

1 Answer

Jeewoo Chung
Jeewoo Chung
609 Points

Your question didn't quite make sense but I see that either you didn't declare the data type of 'firstName' or you just didn't include it in the question? If you didn't declare 'firstName' and give it a data type before that line of code, 'firstName' wouldn't be considered a variable since you didn't give it any sort of data type (data type - the type of variable such as var, int, string, double, bool and et cetera) it wouldn't be considered a variable.

I am not sure if you meant what's wrong with that line of code or if you asked something else since your question didn't quite make sense but if your question was asking why that line of code wasn't working, the solution is simple.

All you have to do is give that variable a data type either by...

Method 1. Declaring the firstName variable before that line of code var (or you could use string instead) firstName;

Method 2. Declaring the data type in the same line of code you wrote var (or you could use string instead) firstName = System.Console.ReadLine();

Hope this helped I'm still learning as well