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

What am I doing wrong? sring firstName; firstName=console.Readline("Leslie");

What am I doing wrong?

sring firstName; firstName=console.Readline("Leslie");

6 Answers

Steven Parker
Steven Parker
231,248 Points

Cody was right about watching out for spelling, but that must also include upper and lower case. Readline is not the same as ReadLine.

Don't be confused by Krzysztof - I think he might have been giving you advice for a different challenge entirely (perhaps from a different course)!

Now in this challenge, the first step is to Declare a variable named firstName and initialize it to the string returned from a call to Console.ReadLine(). You were very close, you just forgot that ReadLine takes input from the keyboard, not from a parameter. So just leave that out and you'd have:

string firstName; firstName=console.ReadLine();  // notice no value passed to ReadLine

Which is fine, but you can also combine the declaration and assignment together like this:

string firstName = console.ReadLine();
Krzysztof Kucharzyk
seal-mask
.a{fill-rule:evenodd;}techdegree
Krzysztof Kucharzyk
Front End Web Development Techdegree Student 4,005 Points

First things first, correct your spelling: Sring -> replace with String. Then you have to declare a variable firstName and store your name in it:

This is task 1:

String firstName = "Leslie";

Then call the print function (Task 2):

String firstName = "Leslie";
console.printf("Leslie can code in Java!");

Oops! Just a bit of a spelling error. Happens to us all! Sring should be spelled string.

Thanks.

Vikrant Bhosale
PLUS
Vikrant Bhosale
Courses Plus Student 2,680 Points

string firstName = Console.ReadLine();

         string firstName = Console.ReadLine();
Christoffer Horneland
Christoffer Horneland
4,627 Points

string firstName = Console.ReadLine(); Console.WriteLine("firstName");