software master at the intersection of technology, science and art



lambda expressions

Lambda expressions are simply functions/methods.

c => c+1 is a function which takes one argument and returns the value c+1. Although this is a simple example, it does exemplify a lambda expression. Lamba expressions are core to functional programming. The examples below show a more complex use in the defintion of a delegate. Give the following definition.

public delegate int ChangeInt(int x)

Using a lambda expression and anonymous type a delegate method and initialization is quite terse.

ChangeInt myDelegate = x => x*2;