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 trialNic Harrington
825 PointsC# Basic Coding Challenge - \" Not Working
I'm unsure why my code \""
is being marked as incorrect for the coding challenge that asks me to have it print "Hello, Treehouse"
using System;
class Program
{
static void Main(string[] args)
{
var name = "Treehouse";
Console.WriteLine("Hello, " \"" name);
}
}
When I review the video, it states that I use \"
to escape from using double-quotes. Am I missing something?
1 Answer
ygh5254e69hy5h545uj56592yh5j94595682hy95
7,934 Points// Your code
Console.WriteLine("Hello, " \"" name);
// Correct code
Console.WriteLine("Hello, " + name);
// They want you to combine "Hello, " with name
// You do that with +
// You don't need \"" in this scenario because "Hello, " has an opening quote and a closing quote
// also there is no need to add addition quotes to "Hello, " string
// the (\") allows you to add quotes within quotes, see example below
Console.WriteLine("He said, \"I won't be able to make it today\".")
// As you can see, we have quotes within quotes. If we did not have (\") our Console.WriteLine would not
// work the way we wanted it.