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

instantiation

what's wrong with my code? can you help

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

    }
}

2 Answers

Shadab Khan
Shadab Khan
5,470 Points

Hi,

'mike' has to be an object (instance) of class Frog. When you say, new mike(), you're creating an object of class mike, which doesn't exists.

In Program.cs, your code should look like below :

namespace Treehouse.CodeChallenges
{
    class Program
    {
        static void Main()
        {            
           Frog mike = new Frog();
        }
    }
}

Let me know if you have further questions. All the best!

Chris Jones
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Jones
Java Web Development Techdegree Graduate 23,933 Points

Hey Innocent,

You need to change the frog variable to mike per the instructions. So, your code should be:

Frog mike = new Frog();

new Frog() is creating a new Frog object using the Frog class as a template/cookie cutter, so to speak. You don't have a class called mike, so you can't say new mike().

I hope that helps! Let me know if you have any more questions!