BKStart a conversation ↗

Be careful of deferred execution

Take the following code, if you have ReSharper installed you’ll be warned that there is possible multiple enumeration of your IEnumerable, this means that Select will be repeated twice for everything in the array.

ToArray()

One solution is to enumerate once and immediately after the select by calling .ToArray.

Guava / Java

It’s not just C# that you need to be careful with, take the Google Java library Guava.

We don’t get the same nice warning in IntelliJ* yet the solution in this case is much the same.

*IntelliJ

If you’re from a MS background like me and doing any Java, then do yourself a favour and use IntelliJ, it’s much easier to use.