All pastes #2074134 Raw Edit

Lambda question

public text v1 · immutable
#2074134 ·published 2011-06-03 14:53 UTC
rendered paste body
// Let's say there's a function that takes an Action<int>
public FunctionThatTakesDelegate(Action<int> callback)
{

}

// And you have a function that matches Action<int>
public void DoSomethingWithInt(int intToUse)
{

}

// I've seen people do something like this before:
FunctionThatTakesDelegate( value => DoSomethingWithInt(value) );

// Is this identical to:
FunctionThatTakesDelegate( DoSomethingWithInt );

// If so, why would they use the lambda expression?