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

Nick Torchio
Nick Torchio
912 Points

One of the first C# challenges

I'm showing error cs1605 and its detected on line (9,22). As you can see my code ends on line 3 and I can't even access the 9th line. Could somebody help me past this issue?

CodeChallenge.cs
Console.ReadLine();
string firstName;
Console.WriteLine(firstName);

2 Answers

Steven Parker
Steven Parker
231,269 Points

You forgot to initialize your variable.

You didn't say which task you were on, but task 1 says, "Declare a variable named firstName and initialize it to the string returned from a call to Console.ReadLine()."

You do have a call to ReadLine, but you didn't assign the return value to anything. You should have something more like this for task 1:

string firstName = Console.ReadLine();

Apparently the challenge let your isolated call slip by task 1, you might want to report this as a bug to Support.

Nick Torchio
Nick Torchio
912 Points

I was worried that that could have been the case with getting past the first part and not being able to complete the second afterwards. Thank you.

On the video Receiving Input about minute 3:44 shows the example explaining the answer for task 1

string entry = System.Console.ReadLine();
Steven Parker
Steven Parker
231,269 Points

:warning: Be aware that the video examples will not be exactly what the challenge requires.