What am I doing wrong here? How can I execute my action?
var recurse = new Action<IItem, Int32>((item, depth) =>
{
if (item.Items.Count() > 0) recurse(item, depth + 1); // red squiggly here
// ...
});
I'm getting a red squiggly when calling recurse
saying "method, delegate or event expected".
Update
I've accepted Homam's answer. I'd just like to add/share another syntax for the same... But which I find a bit easier on the eyes...
Action<IEnumerable<Item>> Recurse = null;
Recurse = item =>
{
if (item.Items != null) Recurse(item.Items);
// ...
};