Method Output: Lesson 3 Return Errors

Fix the error by changing the return type of the CountThePlanets() method.

error CS0029

  static void Main(string[] args)
    {
      Console.WriteLine(DecoratePlanet("Mars")); 
      Console.WriteLine("Is Pluto really a dwarf...?");
      Console.WriteLine(IsPlutoADwarf());
      Console.WriteLine("Then how many planets are there in the galaxy...?");
      Console.WriteLine(CountThePlanets());
    }
    
    static string DecoratePlanet(string planet)
    {
       return $"*..*..* Welcome to {planet} *..*..*";
    }
    
    static bool IsPlutoADwarf()
    {
      return bool answer = true;
    }
    
    static string CountThePlanets()
    {
      return "8 planets, usually";
    }

What did I do wrong? So grateful, many many thanks for reading :smile:

The error is in the return statement. In C# you can’t return an assignment to a variable. You’ll need to make the assignment to your variable, and then return it on the next line.

1 Like