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 Combining Strings

Systematic error or user Error?

Im using the parameters it tells me to use and when I try to preview my code it gives me a whole different code.Help?

Program.cs
using System;

class Program
{

    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"));
    }

}

3 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there, Kevin Ortiz! This is just a very minor user error. In these challenges, especially dealing with strings, it's doing a check to see that the string you produce is exactly like the string it's expecting. In this case, you have a couple of extra spaces in your string. You have an extra space at the beginning and an extra space at the end. So essentially, you have a scenario where it's testing something like:

" Hello World " == "Hello World"

... and those two don't match up exactly. The former has two extra spaces.

You'll need to remove the extra spaces.

You typed:

return " I think " + Foodone + " and " + Foodtwo + " are tasty! ";

But you meant to type:

return "I think " + Foodone + " and " + Foodtwo + " are tasty!";

Hope this helps! :sparkles:

I appreciate the reply, my answer is still not coming out correctly, so at this point I need someone to write out the code correctly in order for me see what I'm doing wrong or what I'm just not doing.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi, Kevin Ortiz! Here is your code very slightly altered and passes the test for me. If it does not pass for you, the implication there is that something is cached somewhere, and you may need to hit the "restart challenge" button:

using System;

class Program
{

    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"));
    }

}

All I did was remove the preceding and trailing space from your string :smiley:

I appreciate you so much Jennifer Nordell it was starting to become real frustrating but you helped me out so much even if it was a simple fix, thank you. I will try and pay more attention to details like spaces.