Skip to content

Instantly share code, notes, and snippets.

@luisdeol
Last active January 11, 2018 00:07
Show Gist options
  • Save luisdeol/c1b22c83319854ef3859b50e6570f3be to your computer and use it in GitHub Desktop.
Save luisdeol/c1b22c83319854ef3859b50e6570f3be to your computer and use it in GitHub Desktop.
Using Lambda Expressions
using System;
namespace create_implement_events_callbacks
{
class Program
{
public delegate int Calculate(int x, int y);
public delegate void ShowMessage(string message);
static void Main(string[] args)
{
Calculate multiCastingCalc = (x, y) => x + y;
multiCastingCalc += (x, y) => x * y;
Console.WriteLine(multiCastingCalc(3, 4));
ShowMessage aMessage = message =>
{
var phrase = $"The message is {message}";
Console.WriteLine(phrase);
};
aMessage("Luis is a cool guy!");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment