I've got this example where I convert a C# 2 delegate example:
Predicate<string> predicate2 = delegate(string n)
{
return n.StartsWith("J");
};
IList<string> namesWithJ2 = Tools.Filter(names, predicate2);
Tools.Dump(namesWithJ2);
to C# 3 lambda syntax example:
var filteredNames = Tools.Filter(names, n => n.StartsWith("J"));
Tools.Dump(filteredNames);
But how to I convert this to lambda syntax? Particularly, how do I get the two parameters (object s, DoWorkEventArgs args) to be passed using the "=>"?
_worker.DoWork += delegate(object s, DoWorkEventArgs args)
{
BackgroundWorker worker = s as BackgroundWorker;
for (int i = 0; i < 10; i++)
{
if (worker.CancellationPending)
{
args.Cancel = true;
return;
}
Thread.Sleep(1000);
worker.ReportProgress(i + 1);
}
};