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
currentmeant? Is that points to the variablehazmatRate? - What does
Aggregateactually does?