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 trialshawn khah
15,082 Pointshelp plz
Challenge Task 2 of 5
Create a public static method named Add that matches the signature of the MathOperation delegate. Inside the method, return the result of number + number. Bummer! Your code could not be compiled. Please click on "Preview" to view the compiler errors. Restart Preview Get Help Recheck work Program.cs
1 using System; 2 ā 3 namespace Treehouse.CodeChallenges 4 { 5 class Program 6 { 7 ā 8 delegate int MathOperation(int number); 9 public static void Add(string[] MathOperation); 10 { 11 console.WriteLine("number" + "number"); 12 } 13 static void Main(string[] args) 14 { 15 ā 16 } 17 } 18 }
using System;
namespace Treehouse.CodeChallenges
{
class Program
{
delegate int MathOperation(int number);
public static void Add(string[] MathOperation);
{
console.WriteLine("number" + "number");
}
static void Main(string[] args)
{
}
}
}
1 Answer
Steven Parker
231,198 PointsYour function signature does not match the provided example.
The challenge states that you should create a method that "matches the signature of the MathOperation delegate"
A function signature is defined by the number and type of parameters it takes, and the type of the value it returns. The MathOperation delegate takes an int parameter, and returns an int value. But you created Add to take a string array (string[]
) and return nothing (void
).
Try again with this requirement in mind.