My VS2010 using ReSharper which prompts to converts foreach
to LINQ. It converts from
foreach (var item in quotePrice.ExtraServiceBreakdown)
{
hazmatRate = (quoteRequest.IsHazMat && item.Id == VitranHazmatCode) ?
item.Cost : hazmatRate;
}
to
hazmatRate = quotePrice.ExtraServiceBreakdown.Aggregate(
hazmatRate, (current, item) =>
(quoteRequest.IsHazMat && item.Id == VitranHazmatCode) ?
item.Cost : current);
I have two questions here,
- What does
current
meant? Is that points to the variablehazmatRate
? - What does
Aggregate
actually does?