C# C# Basics Strings Strings

Amah Martin
Amah Martin
11,264 Points

C# Basics Quiz Question on Escape Characters and Strings

I am absolutely stumped on this quiz question and would like to find out the ideal solution they are looking for. Here is the question:

Please fill in the correct answer in each blank provided below. Fill in the blanks to complete this code so it will compile and print "Hello, Treehouse!" out to the terminal.

using System;

class Program {

static void Main(string[] args)
{
    var name = "Treehouse";
    Console.WriteLine( __"Hello, __ name __ !";
}

}

My response:

using System;

class Program {

static void Main(string[] args)
{
    var name = "Treehouse";
    Console.WriteLine($"\ "Hello, { name }\" !";
}

} When I run this in a workspace, the first blank response gives me the correct result but the quiz states it's wrong as well as the last blank response. I am completely stumped on the last one since I can't figure how to get the very last quotation mark to print with name = "Treehouse" like they want it.

I appreciate the help!

2 Answers

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 51,979 Points

There is an example in this video @2:02 that shows

string name = "Jay"
Console.WriteLine($"Hello {name}!");

This is what the quiz is looking for. I don't think you need to print the quotes.

Amah Martin
Amah Martin
11,264 Points

You're right Kris, for some reason I was under the impression the answer had to be related to using escape characters since that was the video I watched previous to the quiz. I was definitely making it harder than it should have been. Thanks!