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 trialDirk Walzel
5,431 PointsStuck in Actions and Funcs => Step1 - Did you return number * number? Yeah, I did! ;(
I am stuck at this step, what really bothers me is the make the Func public.
In VS the following code runs
using System; namespace CourseLinq { class Program { static public Func<int, int> Square = delegate (int number) { return number * number; };
static void Main(string[] args)
{
Console.WriteLine(Square(5));
Console.ReadLine();
}
}
}
but in TeamTreehouse I get an error, does your anonymous delegate return number*number.
I also tried, which again worked in VS
using System; namespace CourseLinq { class Program { static void Main(string[] args) { Func<int, int> Square = delegate (int number) { return number * number;
};
Console.WriteLine(Square(5));
Console.ReadLine();
}
}
}
Here I get in TeamTreehouse the message is Func public.
Any ideas?
Thanks a lot in advance
using System;
namespace Treehouse.CodeChallenges
{public class Program
{
static public Func<int, int> Square = delegate(int number)
{ return number*number;};
}
}
1 Answer
Steven Parker
231,198 PointsThe field should not be "static".
Also, the challenge syntax checker apparently wants to see spaces around the multiply operator (*
).
Dirk Walzel
5,431 PointsDirk Walzel
5,431 PointsCame back and it worked ''' public Func<int, int> Square = delegate (int number) { return number * number; }; '''