this post was submitted on 23 Jan 2026
5 points (100.0% liked)

C Sharp

1786 readers
1 users here now

A community about the C# programming language

Getting started

Useful resources

IDEs and code editors

Tools

Rules

Related communities

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[โ€“] labsin@sh.itjust.works 2 points 2 months ago (1 children)

In later .net version for loops can be slower than linq queries. If the compiler knows the iteration does not cause side effects, it often already does not allocate and can even vectorize some loops, so .Sum(...) might be faster then a manual for loop.

Optimizing without benchmarking is often wasted effort.

[โ€“] xianjam@programming.dev 1 points 2 months ago

Funnily enough, that engineer also disallowed Linq because it was slow. It's been 7 years since I've worked with him. wonder if he ever changed his tune.