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# Querying With LINQ Functional Programming in C# Actions and Funcs

what am I doing wrong it looks right but will not process

so am I missing an item

Program.cs
using System;

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

    }
} 

Challenge Task 1 of 3 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.

2 Answers

Steven Parker
Steven Parker
231,275 Points

You forgot to end your delegate assignment with a semicolon.

Also, the "check work" seems to have it's own ideas about syntax. It seems to want a space between the int specs of the Func, and it also wants spaces around the multiply operator.

        public Func<int, int> Square = delegate (int number)
        {return  number * number;};

You might want to report the space issue as a bug to Support, it might even get you a "special Exterminator badge".

thank you, damn spaces