C# Querying With LINQ Functional Programming in C# Delegates

help 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 }

Program.cs
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
Steven Parker
170,273 Points

:point_right: Your 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.