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 trialSikder Qais
339 PointsQuestion Broken
using System;
class Program
{
static string Eat(string par1, string par2)
{
return ("I think apples and blueberries are tasty!");
}
static void Main(string[] args)
{
Console.WriteLine(Eat("apples", "blueberries"));
Console.WriteLine(Eat("carrots", "daikon"));
}
}
2 Answers
Steven Parker
231,269 PointsThe example output given in the question is only valid when method is called as Eat("apples", "blueberries")
. If different arguments are used, the method should return a string that contains those arguments.
The code shown here only returns a literal string and ignores the arguments. It needs to be re-coded so that it builds up the string using the arguments that are passed to it. This can easily be done using String Concatenation or String Interpolation.
Emeric Juhasz
3,476 Pointsusing System;
class Program {
// YOUR CODE HERE: Define an Eat method!
static string Eat(string foodOne, string foodTwo)
{
return ($"I think {foodOne} and {foodTwo} are tasty!");
}
static void Main(string[] args)
{
Console.WriteLine(Eat("apples", "blueberries"));
Console.WriteLine(Eat("carrots", "daikon"));
}
}
Sikder Qais
339 PointsSikder Qais
339 PointsDefine an Eat method that takes two string parameters. Eat should return a string in the form "I think [first parameter] and [second parameter] are tasty!" (without square brackets). For example, the call Eat("apples", "blueberries") should return "I think apples and blueberries are tasty!"
When I run any code in this section it returns something about eggs and falafel.