String Performance: Encoding and Decoding Strings

Encoding and decoding strings to and from a byte[] is used a lot in programming. Performance results are for using the formatting options ASCII, Unicode, UTF8, and UTF32, Latin and BigEndianUnicode. Updated February 2023

String Performance: Combining Strings with the StringBuilder

In programming, efficient string concatenation is crucial. Utilizing the StringBuilder class, especially within loops, offers better performance and reduced memory usage. Methods like AppendFormat() and AppendLine() provide formatting and localization benefits. Benchmark results show StringBuilder's significant speed advantage, with minimal memory allocations. Consistently using StringBuilder for string concatenation is recommended.

Internationalization and Localization: Overview

These articles will show when you need to use globalization, even when the performance might not be the best. Believe me, you will thank me later. I typically do not use globalization patterns for application logging. Updated February 2023.

String Performance: Formatting

This article discusses the performance differences using string.Format() and interpolation and stresses the importance of using globalization with any string shown to the user. Updated January 2023.

Collection Performance: A Comprehensive Benchmark Analysis of Collection Types in .NET Beyond Arrays and Lists

This article conducts a comprehensive benchmark analysis of various collection types in .NET beyond arrays and lists. It explores the performance of iteration methods, revealing significant differences among types, providing valuable insights for developers to choose the most performant collection type based on their code requirements.

Collection Performance: Adding Items to a Collection

The most popular way to add an item to a collection is by using Add(). The other way is by using Insert() or Prepend(). This article shows performance results for these three methods.

Everything That Every .NET Developer Needs to Know About Disposable Types: Part  2 – Properly Implementing the IDisposable Interface

The second part of this article series focuses on the proper implementation of the IDisposable interface for types in .NET that require memory management. It emphasizes the importance of preventing virtual memory leaks and provides a step-by-step guide to implement the IDisposable pattern correctly, including an example template for ease of use. The article also addresses the implementation of IDisposable in types that inherit from other disposable types.

Collection Performance: Looping Over Reference Type vs. Value Type

Since most of the types and collections I create are typically business objects, I wondered if collections of simpler types would be faster. I decided to benchmark the difference between a List (reference type) with a List (value type).

Collection Performance: Sorting the Record Type

This article shows the difference between sorting a normal class type with a record class type.

Collection Performance: Sorting Collections

There are several ways to sort a collection in .NET. Some of the sorting methods are part of LINQ. Let’s look at the methods that are part of the System.Collections.Generic namespace.