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

Alec Price
Alec Price
213 Points

not sure what its asking the video didnt go into detail about variables being used this way

what forum can i find to ask questions besides here

CodeChallenge.cs
var  firstName = Console.ReadLine();
Console.WriteLine("firstName");

1 Answer

  • C# is not like Python; you have to assign a specific variable type when wanting a particular type.
  • Also, you only quote that which you exactly want to quote. For variables, you do not quote it, so the program knows to search for its value in the code or imports.
string firstName = Console.ReadLine();
Console.WriteLine(firstName + " rocks!");
On a side note: Good work otherwise, but you do want to stylistically watch needless spacing like in between var and firstName. Though I do normally space to my preferences, too, yet only when it is consistently plausible for enhancement of ease of readability; else, I always follow best practices conventions spot-on.
Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there Gavin Schilling! I've moved your comment to an answer. This has the benefit of marking the question as "Answered" in the forums and allows for voting of your answer. On a side note, var is perfectly valid for this challenge and does not necessarily need to be explicitly told to be a string. Thanks for helping out in the Community! :sparkles: