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# Objects Object-Oriented Programming Instantiation

Cant seem to get my frogs in a row. Have tried Frog mike - new Frog(); and var mike = new Frog(); and even tried var mik

I am thinking that the code is close and have tried every variation I can think of. Can someone point me in a better direction?

Program.cs
namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {            
         var frog = new Frog(mike) ;
        }
    }
}
Frog.cs
namespace Treehouse.CodeChallenges
{
  class Frog
  {
    public string name;

    {name = name;}
  }
}

1 Answer

Steven Parker
Steven Parker
231,198 Points

Did you pass task 1?

For task 1, you were asked to create an empty class named Frog, but it looks like you have some stuff in there. It should stay empty for task 2, did you add that stuff later? Anyway, that stuff is not part of this challenge (nor is it proper syntax) so keep the Frog class empty.

Now for task 2, you did get close but I see two errors:

  • the new variable name should be mike but you wrote frog
  • a default constructor as you are using here would not take an argument

So you probably want something more like:

            var mike = new Frog();