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# Intermediate C# Abstraction Interfaces

Benson Gathee
PLUS
Benson Gathee
Courses Plus Student 1,280 Points

Does Increment have a constructor that takes no parameters? What is this error?

In Increment.cs create a class named Increment that implements the IUnaryOperation interface. The Perform method should increment the value passed in by one.

IUnaryOperation.cs
namespace Treehouse.CodeChallenges
{
    interface IUnaryOperation
    {
        double Perform(double value);
    }
}
Increment.cs
namespace Treehouse.CodeChallenges
{
    abstract class Increment  : IUnaryOperation 
    {
        public Increment(){}

        public double Perform(double value) 
        {
            return value+=1;
        }

    }
}

1 Answer

Steven Parker
Steven Parker
231,198 Points

That message is perhaps a bit misleading. The constructor is not the issue.

But the instructions did not say anything about creating an abstract class. Abstract classes cannot be instantiated, which is most likely how the challenge tests the code.