Skip to content

Instantly share code, notes, and snippets.

@webgio
Last active January 26, 2017 09:55
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 webgio/5fd886fa4df9fc00609c192e1513d112 to your computer and use it in GitHub Desktop.
Save webgio/5fd886fa4df9fc00609c192e1513d112 to your computer and use it in GitHub Desktop.
High order function in C#
void Main()
{
var add4To = AddNumber(4);
var newNumber = add4To(3);
Console.WriteLine(newNumber);
// prints 7
}
public Func<int, int> AddNumber(int n)
{
Func<int, int> t = (i) => i+n;
return t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment