C# Querying With LINQ Functional Programming in C# Delegates

Lewis Cowles
Lewis Cowles
74,897 Points

what's going wrong here?

Instantiate a new MathOperation named add and pass it Add method...

Program.cs
using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        delegate int MathOperation(int number);

        public static int Add(int number)
        {
            return number + number;
        }

        static void Main(string[] args)
        {
            MathOperation mathOperation = delegate(int number) {
                return 0;
            };
            MathOperation add = new MathOperaton(Add);

        }
    }
}

1 Answer

Lewis Cowles
Lewis Cowles
74,897 Points

Solved...

using System;

namespace Treehouse.CodeChallenges
{
    class Program
    {
        delegate int MathOperation(int number);

        public static int Add(int number) {
            return number + number;    
        }

        public static int Square(int number) {
            return number * number;
        }

        static void Main(string[] args)
        {
            MathOperation add = new MathOperation(Add);
            MathOperation square = new MathOperation(Square);
        }
    }
}