I use Resharper, and when I make a few lines of code like this:
foreach (var posCombination in possibleCombinations)
{
if (posCombination .Count == combo.Count && posCombination .Select((l, i) => combo.Contains(l)).All(b => b))
{
return true;
}
}
return false;
It will ask me if I want to convert it into a LINQ-expression:
return possibleCombinations.Any(possibleCombination =>
possibleCombination.Count == combo.Count
&& possibleCombination.Select((l, i) => combo.Contains(l)).All(b => b));
I've had a lot of people tell me that they have a hard time reading whats going on in a LINQ statement... So why would I want to convert it to a LINQ-expression, if it makes my code less readable?