C# Querying With LINQ Functional Programming in C# Actions and Funcs

Thor Giversen
Thor Giversen
771 Points

Problems 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

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    public class Program
    {
        public Func<int, int> Square = delegate(int number)
        {
            return number * number;
        };
    }
}
Florian Stegemann
Florian Stegemann
13,466 Points

Hm weird, I just copied your code into the challenge and it completes successfully. What kind of error message are you getting?

2 Answers

Steven Parker
Steven Parker
143,175 Points

I 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
Thor Giversen
771 Points

Just tried it again using a different browser and now it works perfectly.

Thanks anyway :)