Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,921 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!