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 trialThor Giversen
771 PointsProblems with a Func statement
I am trying to complete a codechallenge in the Querying with LINQ track. Here is the problem assignment that i am given :
In the Program class, declare a public Func field named Square that takes an int and returns an int. Use an anonymous method to assign a delegate that takes an int parameter named number and returns the result of number * number.
i donΒ΄t understand why my code is not accepted and i would be gratefull for any hints or explanations.
best regards. Thor
using System;
namespace Treehouse.CodeChallenges
{
public class Program
{
public Func<int, int> Square = delegate(int number)
{
return number * number;
};
}
}
2 Answers
Steven Parker
231,275 PointsI can confirm Florian's results. Pasting in the code above passes task 1.
Try again and see if it works for you now.
Thor Giversen
771 PointsJust tried it again using a different browser and now it works perfectly.
Thanks anyway :)
Florian Stegemann
Full Stack JavaScript Techdegree Student 22,660 PointsFlorian Stegemann
Full Stack JavaScript Techdegree Student 22,660 PointsHm weird, I just copied your code into the challenge and it completes successfully. What kind of error message are you getting?