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 Variables

im not understanding the question

string = bookTitle; System.Console.Write("books boy"); string bookTitle = System.Console.Write();

CodeChallenge.cs
string = bookTitle;
System.Console.Write("hey abernathy");
string bookTitle = System.Console.ReadLine();

1 Answer

Edvin Linden
seal-mask
.a{fill-rule:evenodd;}techdegree
Edvin Linden
Full Stack JavaScript Techdegree Student 8,040 Points

I am not sure if you are having trouble with the step "Variables" or "Console I/O" but to declare a variable in C# you first specify the type and then the name of the variable. The first line in your code is wrong as it is trying to give the type a value instead of the variable. This is the correct way to declare a variable:

string bookTitle;

If you want to use the input value from the console as the variables value you do exactly as you've written in your post:

string bookTitle = System.Console.ReadLine();

If you instead want to use the variable as an output to the console you need to pass that variable to the function System.Console.Write(), like this:

System.Console.Write(bookTitle);

Did this help with your problem?