Resharper says I can but I don’t see how. There are several examples of the form:
foreach (ItemType Item in ListOfItems)
if (ConditionalInvolvingItem)
Total += ItemProperty;
Of course I could make a sublist on the conditional and then sum the items in the sublist but this would be no clearer and would run slower.
ReSharper is a handy tool, but keep in mind its suggestions aren’t always necessarily more performant or self-explanatory. Such is the case here. It’s really a toss-up. I’m sure you already have a LINQ statement in mind, but I’d imagine this example would look as such: