ReSharper and Loop to LINQ in C#

In class the other day, I was surprised how many of the attendees didn’t realise that ReSharper will suggest converting loop statements to LINQ expressions in Visual Studio where appropriate.

Just to demonstrate the point, I’ve created a short video showing it doing just that.

You can see I’m doing the third test in Bob Martin’s ‘Bowling Game’ kata when ReSharper suggests turning the implementation of the scoring method from a loop into the use of  LINQ’s .Sum() aggregation operator.

enjoy

 

Post navigation