Skip to content

Instantly share code, notes, and snippets.

@snippe
Created December 5, 2014 12:37
Show Gist options
  • Save snippe/9f2c7216b3731cdf1bcf to your computer and use it in GitHub Desktop.
Save snippe/9f2c7216b3731cdf1bcf to your computer and use it in GitHub Desktop.
Different forms of Lambda Expressions
class Program
{
delegate int Delegate1();
delegate int Delegate2(int a);
delegate int Delegate3(int a, int b);
static void Main(string[] args)
{
//No parameters
Delegate1 del1 = () => PrintValue();
int val1 = del1(); //1
//One parameter
Delegate2 del2 = x => x * x;
int val2 = del2(2); //4
//Multiple parameters
Delegate3 del3 = (x, y) => x * y;
int val3 = del3(2, 3); //6
}
static int PrintValue()
{
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment