Example
Our previous code looks like this.
using System;
namespace FunctionalProgramming
{
class Program
{
static void Main(string[] args)
{
Action<string> sayGreeting;
Func<string, string> conversate = delegate (string message)
{
Console.WriteLine(message);
return Console.ReadLine();
};
string input = conversate("What's your name?");
sayGreeting = delegate (string greeting)
{
Console.WriteLine(string.Format(greeting, input);
};
sayGreeting("Hello, {0}");
sayGreeting("Bye, {0}");
}
}
}
Which part of code that could be lambdify?
Func<string, string> conversate = delegate (string message)
{
Console.WriteLine(message);
return Console.ReadLine();
};
// after lambdify
Func<string, string> conversate = (message) =>
{
Console.WriteLine(message);
return Console.ReadLine();
};
and
sayGreeting = delegate (string greeting)
{
Console.WriteLine(string.Format(greeting, input);
};
// after lambdify
sayGreeting = (greeting) =>
{
Console.WriteLine(message);
return Console.ReadLine();
};