Category: Performance
Alternate Lookup for Dictionary and HashSet in .NET 9
September 10, 2024 3 minutes read In .NET 9, a new method called GetAlternateLookup<TKey, TValue, TAlternate>() has been introduced for hash tables classes, including Dictionary<TKey, TValue>, HashSet<T>, ConcurrentDictionary<TKey, TValue>, FrozenDictionary<TKey,...
Faster Dictionary in C#
September 2, 2024 5 minutes read In the .NET Base Class Library, Dictionary<TKey, TValue> is an essential key-based hashtable providing constant time access to values. This means accessing dictionary[key] takes...
Improve C# code performance with Span<T>
April 24, 2024 9 minutes read Welcome to our exploration of System.Span<T> and System.ReadOnlySpan<T>, two powerful structures introduced in C# 7.2 back in 2017. As a type-safe way to access...
.NET 8 Top 10 New Features
April 24, 2024 7 minutes read .NET 8 has been officially released in November 2023. You can download it here. Designated as an LTS (Long Term Support) version, it guarantees...
WPF vs WinForms – Making the Right Decision in 2024
April 24, 2024 7 minutes read If you’re a developer faced with the decision of selecting between Windows Presentation Foundation (WPF) and Windows Forms (WinForms) commonly referred to as WPF...
.NET Micro-Optimization and Refactoring Trick
May 31, 2023 3 minutes read 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...
Managed pointers, Span, ref struct, C#11 ref fields and the scoped keyword
October 25, 2022 9 minutes read The concept of managed pointer exists in the NET runtime and C# since the inception of the platform in the early 2000. Managed pointers...