Improve your .NET code quality with NDepend

.NET Micro-Optimization and Refactoring Trick

Recently, I made an interesting observation regarding Dictionary<string,T>: the method TryGetValue() is faster when building  with new Dictionary<string,T>(StringComparer.Ordinal). This performance difference can be attributed to the fact that StringComparer.Ordinal performs...
Patrick Smacchia May 31, 2023

Managed pointers, Span, ref struct, C#11 ref fields and the scoped keyword

The concept of managed pointer exists in the NET runtime and C# since the inception of the platform in the early 2000. Managed pointers belong mostly to the pointer world,...
Patrick Smacchia October 25, 2022

Improve C# code performance with Span<T>

C# 7.2 introduced the structure System.Span<T>. First we’ll present a concrete example where Span<T> helps achieve better performance. Then we’ll explain what makes Span<T> so special. Span<T> primary goal is...
Patrick Smacchia February 21, 2022