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 trialChris Smith
689 PointsUsing Return Values and Escapes
Not sure I fully understand the return value in this instance where it's asking to add the \" escape sequence.
using System;
class Program
{
// YOUR CODE HERE: Define a Quote method!
static string Quote(string phrase)
{
string saying = "\"phrase\"";
return Console.WriteLine();
}
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
jb30
44,806 PointsYou have properly escaped the quotation marks, so printing out saying
would give you "phrase"
. If instead you want saying
to include the value stored in phrase
, you would need to use string concatenation or string interpolation.
The challenge wants you to return a string, such as saying
, and not Console.WriteLine()
.
Chris Smith
689 Pointsjb30 thanks for hanging in there with me! I appreciate the heck out of it. I feel like i tried everything. But it seems I needed to try one more thing and I finally got it!!!! Thanks
Chris Smith
689 PointsChris Smith
689 Pointsjb30
Thanks. I'm starting to grasp more and more. But I am certainly on the struggle bus here with this challenge. I've gone ahead and rewatched the method's series and the return series. Not sure I'm hung up on that as I am now on the escape method.
` using System;
class Program {
}
`
When I submit that, I don't even get anything in the console. It says: "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."'."
So I don't even get a response as to where the errors might be other than that explanation which does not compute to me because I'm using \" for the double quote escape sequence.
Any advice here is grately appreciated.
jb30
44,806 Pointsjb30
44,806 PointsThe challenge wants you to add your code in the Quote function and leave the Main function unchanged.