C# C# Basics Strings Escape Sequences

Austin Stewart
Austin Stewart
2,646 Points

I cant figure out what im doing wrong the error i get is We called Quote("Patrick, I don't think wumbo is a real word.

We called Quote("Patrick, I don't think wumbo is a real word."), but we got a return value of: 'Patrick, I don't think w

Program.cs
using System;

class Program
{

    static string Quote(string phrase)
    {
    return phrase;

    }


    static void Main(string[] args)
    {
        // Quote by Maya Angelou.
        Console.WriteLine(Quote("When you learn, teach. When you get, give."));
        // Quote by Benjamin Franklin.
        Console.WriteLine(Quote("No gains without pains."));
    }

}

2 Answers

Jennifer Nordell
STAFF
Jennifer Nordell
Treehouse Staff

Hi there, Austin Stewart ! I received your request for assistance. It looks like you're doing fairly well, but there seems to be a misunderstanding of what they're asking :smiley: They want you to return the string together with the actual quotation marks a part of the string that is returned. They actually want the quotation marks printed to the console.

Try this in your return line:

return "\"" + phrase + "\"";

or

return '"' + phrase + '"';

In the first example I used the \ to escape the quotation marks to say they are not the beginning nor ending of a string, rather they are the literal quotation marks. In the second example, I used the single quotes to encapsulate the quotation marks and then concatenated the phrase inside them. The result of this is that quotation marks will be added to either side of the string as part of the string or the literal character for quotation marks and be printed to the screen.

Hope this helps and clears up what they're after! :sparkles:

Austin Stewart
Austin Stewart
2,646 Points

wow thanks i knew it was something simple i just didn't think to use in as a concatenation.