
The Battle of Loops: foreach vs. ForEach in C#
foreach is a language statement; List<T>.ForEach() is a method that takes a delegate. They look interchangeable, but they compile to different code with different performance profiles — and F...

foreach is a language statement; List<T>.ForEach() is a method that takes a delegate. They look interchangeable, but they compile to different code with different performance profiles — and F...

I’ve been immersed in the .NET world since version 1.0, and it’s been an incredible journey. Throughout the years, .NET has consistently been my primary development tool of choice. In this article,...

As detailed in a previous article, an enumerator serves as a representation of a pull stream. To obtain the next item, clients must invoke the MoveNext() method. If it returnstrue, it indicates a s...

As I explained in a previous article, IEnumerable<T> is an interface that enforces the requirements for the source of a foreach statement. Any type that implements IEnumerable<T> can be...

Determining at runtime whether a type supports foreach is deceptively hard — simply checking for IEnumerable<T> misses value-type enumerators, non-generic patterns, and extension-method scena...

Checking whether a type is a valid foreach source in a Roslyn analyzer isn’t as simple as testing for IEnumerable<T> — the C# spec allows any type with a compatible GetEnumerator() method, in...

Behind the elegant facade of LINQ lies a meticulously engineered core designed for more than just simplicity. This article delves into the technical intricacies of LINQ, focusing on the “speed opti...

The C# foreach loop hides a surprising amount of compiler-generated code — and what gets generated depends entirely on the collection type you hand it. Understanding this lets you write custom coll...

.NET has over a dozen collection interfaces — IEnumerable<T>, ICollection<T>, IReadOnlyList<T>, IAsyncEnumerable<T>, and more — each adding specific capabilities. Choosing t...

Introduction ImmutableArray<T> is the go-to immutable collection when you need array-like performance without mutation — but does iterating it actually match regular array speed? This articl...

I’ve been writing articles about performance in .NET for several years but I frequently find in the comments the famous quote from the Donald Knuth’s paper “Structured Programming with go to Statem...

What is SIMD? SIMD lets you process 4, 8, or 16 values in a single CPU instruction — turning a loop over a million floats from seconds into milliseconds. .NET exposes SIMD through Vector<T> ...

Before .NET 7 Before .NET 7, writing a single Sum<T>() method that worked across int, float, and double was either impossible or required ugly workarounds. Generic math — powered by static a...

NOTE: This series of articles use TypeChain to make strongly-typed calls to Ethereum. Please check its documentation and discussion board to learn how to set it up. It’s also assumed some knowledge...

In previous posts I explained how React Query can be used to query smart contracts, that is, to perform read calls. Now I’m going to explain how to mutate, that is, to execute transactions on the b...