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 Strings Escape Sequences

When clicking preview for the code challenge I get a completely different result from what my code should display

I'm trying to pass the quote "When you learn, teach. When you get, give", but when I hit preview it brings up something

Program.cs
using System;

class Program
{

    // YOUR CODE HERE: Define a Quote method!
    static string Quote(string a)
    {
        return (a);
    }
    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."));
    }

}

4 Answers

There is a note in the instructions:

(Note that the output is surrounded by quotes.)

You'll need to update your return statement:

return ('"' + a + '"');

Thanks for this, but I was confused because the results wouldn't specify an error. It keep bringing up a totally separate quote saying something like "I don't think wumbo exist", which is nowhere in my code.

Yes. A hint. That's what it was trying to do

If you look closely at it: 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 wumbo is a real word.'.

We were expecting

'"Patrick, I don't think wumbo is a real word."'.

you see the double quotes surrounding the expected.

So in other words, its was trying to give me a hint correct? I understand now, although I was expecting a compiler error to research.