Skip to content

Instantly share code, notes, and snippets.

@Fosna
Created January 22, 2016 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fosna/a047fc28e8c216f44c7c to your computer and use it in GitHub Desktop.
Save Fosna/a047fc28e8c216f44c7c to your computer and use it in GitHub Desktop.
It's suggested to use LINQPad 5 (download link: http://www.linqpad.net/download.aspx). See what's the difference between lambda delegate and lambda expression tree.
Func<int, int, int> addDel = (a, b) => a + b;
Console.WriteLine(addDel);
int d = addDel(1, 2);
Console.WriteLine(d);
Expression<Func<int, int, int>> addExp = (a, b) => a + b;
Console.WriteLine(addExp);
addExp(1,2);
Func<int, int, int> addCompiled = addExp.Compile();
Console.WriteLine(addCompiled);
int c = addCompiled(1, 2);
Console.WriteLine(c);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment