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 trialMatthew Tyler
653 Pointsi don't understand this c# question
So on an excersise I was asked to "Declare a variable named firstName and initialize it to the string returned from a call to Console.ReadLine()." and I've tried really hard to answer it but I just don't get it. I'm new to c# and i really don't understand. Also, I look on the previous videos and there is nothing to help me. Can somebody help me out please?
using System;
string firstName = Console.ReadLine();
2 Answers
Chris Kopcow
2,852 PointsYou're right. This SHOULD work. But I think you're a little ahead of the game here, and it's messing with Treehouse.
At this point, I don't think they've really taught you about "using" yet, or at least they don't expect you to use it. So what they really want you to use is
string firstName = System.Console.ReadLine();
to access the System namespace that way rather than with "using." I tried that out, and it worked.
Hope that helps!
Changed to an answer - Dane E. Parchment Jr. (Moderator)
Steven Parker
231,269 PointsMany challenges, like this one, do some of the work for you even though you don't see it. You can usually tell what might have been done for set-up by what the instructions ask you to do.
The code you write here already has access to the "System" namespace, so you don't need a "using" statement or to include it in the method calls. This was hinted by the instructions specifically suggesting the use of "Console.ReadLine".
Steven Parker
231,269 PointsSteven Parker
231,269 PointsIncluding the namespace in the call doesn't hurt but isn't necessary.