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 trialMIGUEL PIETER
Courses Plus Student 756 PointsAssign bookTitle the title of your favorite book
On C# Basics there is: Assign bookTitle the title of your favorite book. How is this done. I'm stocked. What do I do?
1 Answer
Chase Marchione
155,055 PointsHi Miguel,
1) Declaring the variable (named bookTitle, of type string... and using a semicolon to tell the compiler that the statement is over):
string bookTitle;
2) Assigning bookTitle to the title of your favorite book (using the equals sign to specify that a value is to be stored, and putting the string value in double quotes because it is string data):
string bookTitle = "That Book I Like A Lot";
3) Using the System.Console.Write() method to print a specified prompt string (message) to console:
string bookTitle = "That Book I Like A Lot";
System.Console.Write("Enter a book title: ");
4) Storing the user's response back to the bookTitle variable (using the ReadLine() method to get the next line, which is the user's response to the prompt):
string bookTitle = "That Book I Like A Lot";
System.Console.Write("Enter a book title: ");
bookTitle = System.Console.ReadLine();
Hope this helps!
Rafael silva
23,877 PointsRafael silva
23,877 Pointsstring bookTitle = "That Book I Like A Lot";
System.Console.Write("Enter a book title: ");
string bookTitle = System.Console.ReadLine();