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 trialsharon smith
10,527 Pointsre Code Challenge, instantiation and delegate method
The Code Challenge question says to Instantiate a new MathOperation named add
and point it to the Add
method.
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
delegate int MathOperation (int number);
public static int Add (int number)
{
return number + number;
}
static void Main(string[] args)
{
MathOperation add = new MathOperation (Add);
}
}
}
The error message says Bummer! Did you point to the MathOperation
to the Add
method?
I think, yes ???
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
delegate int MathOperation (int number);
public static int Add (int number)
{
return number + number;
}
static void Main(string[] args)
{
MathOperation add = new MathOperation (Add);
}
}
}
3 Answers
Steven Parker
231,198 PointsYour solution is correct. But the challenge apparently doesn't like the space between the name "MathOperation" and the open parenthesis, just remove that space and you'll pass.
You might want to report this as a bug to Support.
sharon smith
10,527 Pointsmany thanks / I thought this was correct, and if not, was having real trouble figuring out why
James Churchill
Treehouse TeacherSharon,
Thanks so much for taking the time to report the bug that you found with this code challenge! I've updated the code challenge so that it'll now allow spaces in your code wherever they're allowed by the compiler.
Thanks, James