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 trialAlan Mills
31,712 PointsWhy / How should I be building a (static?) constructor for this puzzle?
Hopefully my code snippets transfer to this post. I'm not sure what I missed, when learning constructors in C#. Any help is valued, as I'm trying to figure out how / why a static constructor is suggested in this scenario.
Thanks!
namespace Treehouse.CodeChallenges
{
interface IUnaryOperation
{
double Perform(double value);
}
}
namespace Treehouse.CodeChallenges
{
abstract class Increment : IUnaryOperation
{
public double Value;
//static Increment()
//{
//}
// double Perform(double value);
public double Perform(double value)
{
return Value;
}
}
}
1 Answer
Steven Parker
231,198 PointsI can see two issues:
- the "Increment" class should not be abstract
- the instructions say, "The Perform method should increment the value passed in by one."
Alan Mills
31,712 PointsAlan Mills
31,712 PointsNot sure why I was thinking I needed an abstract class. Set it to public to fix. The βreturn valueβ was just trying to bypass that section, while troubleshooting. I was focused on resolving the increment class not having any parameters (or whatever the resulting prompt was). Thanks !!!!