Is it possible to achieve something like this:
Process(
() => InstanceA.PropertyA,
() => InstanceB.PropertyB,
() => InstanceC.List.Select(x => x.PropertyC) // obviously not a proper way to do it
);
The third line would replace:
foreach(var item in InstanceC.List)
{
Process(() => item.PropertyC);
}
Last part:
Process(params Func<object>[] args) // body is in this case irrelevant
So, is there a nifty syntactic sugar that I’ve could use to yield the inner elements of a list back to the outer params argument? Or did I went a step too far?
No but you can concatenate if you really want them to be in the same list.
This evaluates
InstanceC.Listearlier than your code and may not be your intention.