C# C# Basics Strings Combining Strings

Matthew Tandy
Matthew Tandy
1,259 Points

combining strings c# basics

I am so stuck on challenge task 1 of 1 combining strings c# basics. I have no idea how to call my strings individually.

Program.cs
using System;

class Program
{
  static string Eat(string first, string second)
  {
    return first + second;
  }

  static void Main(string[] args)
  {
    string total = Eat("apples"," and blueberries");
    Console.WriteLine($"I think {total} are tasty!");
  }

}
Alex Labins
Alex Labins
12,771 Points

Hello Matthew,

The code you provided does indeed create the desired output to the console, but it is not encapsulated within the Eat() method and the Challenge does not expect that. Try this:

static string Eat(string first, string second)
{
    return "I think " + first + " and " + second " + are tasty!";
}

Make sure to restart the challenge and leave the Main() method as it is when the challenge loads.

1 Answer

Matthew Tandy
Matthew Tandy
1,259 Points

Hi Alex, Thanks for your reply. I now get a build error ; excepted (8,50) From what i can see I am not missing a ;

using System;

class Program {

static string Eat(string first, string second)

{ return "I think " + first + " and " + second " + are tasty!"; }

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

}