C# C# Basics Strings Combining Strings

Austin Stewart
Austin Stewart
2,632 Points

i can't figure out what to do for the return value or how to call apples and blueberries in the string.

Program.cs
using System;

class Program
{

    static string Eat(string foodOne, string foodTwo)
    {

    }
    static void Main(string[] args)
    {
        Console.WriteLine(Eat("apples", "blueberries"));
        Console.WriteLine(Eat("carrots", "daikon"));
        foodOne += " apples";
        foodTwo += " blueberries";
        Console.WriteLine(Eat("I think " + foodOne + " and " + foodTwo + " are tasty!"));

    }

}

2 Answers

<noob />
<noob />
16,609 Points

First of all u have been asked to create a method called Eat which u did correctly!. you defined that the Eat method should return a string. All u how to do is to return the sentence they supply in the example with the 2 parameters as the placeholders. You dont need to call anything, they do it for u in the Main method which runs the program.

    static string Eat(string firstString,string anotherString) {
        return "I think " + firstString + " and " + anotherString + " are tasty!";   

    }
Austin Stewart
Austin Stewart
2,632 Points

so do i need the Console.WriteLine in the Main method still?

<noob />
<noob />
16,609 Points

Nope, you just being asked to create the method. in the Main() method as u see u have this call:

Console.WriteLine(Eat("apples", "blueberries"));
  Console.WriteLine(Eat("carrots", "daikon"));

the staff already called the Eat method for u and passed 2 arguments into them, that will be passed to the function.

Remember, the eat method it just a function that returns a string, in the Main method the actual program is running.