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 […]
Tag: stringbuilder
How Does the StringBuilder Work in .NET? (Part 2)
Part Two: Understanding the Overhead of a StringBuilder To continue exploring how the StringBuilder works, we’ll shift focus and study its logical design. Today, we’ll start by looking at how the type is designed and the overhead involved with creating and using StringBuilder instances. If you missed part one of this series, I explained why […]
How Does the StringBuilder Work in .NET? (Part 1)
Part 1: Why do we need a StringBuilder and when should we use one? After becoming proficient in .NET and C#, developers are likely to learn that they should use a StringBuilder to optimise string manipulation and concatenation. This is not a hard and fast rule for all situations but is generally good advice if […]
Creating Strings with No Allocation Overhead Using String.Create Writing High-Performance C# and .NET Code: Part 4
In this post, I’ll continue my series about writing high-performance C# and .NET code. This time, I will focus on a new(ish) method available on the String type – String.Create. First introduced in .NET Core 2.1, this method is currently planned for inclusion as part of .NET Standard 2.1 once that is released. What Does […]