In this post, I will introduce and demonstrate enhancements to collections in .NET 9 and C# 13 for low-allocation code paths. Specifically, I will demonstrate using a custom IAlternateEqualityComparer and the AlternateLookup on a Dictionary used for efficiently tracking IP address information, keyed on the bytes of IP addresses. My use case, the basis for […]
Tag: C#
Creating, Inspecting and Decompiling the World’s (Nearly) Smallest C# Program
In this post, I thought it might be fun to create the world’s (nearly) shortest C# program and then deep dive into some of the fine details of what happens behind the scenes. This post is not intended to solve a real-world problem but I hope it’s well worth your time spent reading it. By […]
How Does the StringBuilder Work in .NET? (Part 3)
Part Three: How Appending Works and the StringBuilder Expands So far in this series, we’ve learned when we should consider using StringBuilder in our code and learned about the memory overhead of using a StringBuilder. It’s now time to learn how the StringBuilder can “expand” its capacity and support appending string data efficiently. As with […]
Using DateOnly and TimeOnly in .NET 6
In .NET 6 (preview 4), two long-awaited types have been introduced as part of the core library. DateOnly and TimeOnly allow developers to represent either the date or time portion of a DateTime. These two new types are structs (value types) and may be used when your code deals with date or time concepts independently. […]
String Manipulation in C#: Best Practices
Last week my sixth Pluralsight course, “String Manipulation in C#: Best Practices” was released. This new course dives into creating, modifying, searching and parsing strings in .NET. Strings are one of the most used types in .NET applications and In this course, you’ll uncover everything you need to know about strings to use them effectively […]