Collection Performance: Memory Efficiency with AsMemory() in Byte Array Conversion

The article discusses the efficiency benefits of using AsMemory() for byte array conversion, emphasizing reduced memory usage, future-proofing code, and performance optimization. Benchmark results highlight a significant performance advantage, with a 54 times improvement compared to other methods, reinforcing the importance of AsMemory() for optimal performance in memory-sensitive applications.

Collection Performance: Converting Byte Array to Memory<> and ReadOnlyMemory<>

When working with byte arrays, there are two methods to convert to Memory. Using AsMemory() offers performance optimization, efficient memory management, improved code clarity, and future-proofing. Benchmark results show a 57x performance improvement, with no memory allocation. This method is crucial for memory-sensitive applications and large datasets. Utilize AsMemory() for optimal performance and efficient array handling.

Collection Performance: Exploring the Performance Impacts of Array Properties

The post critiques developers’ practices of using properties that return arrays, highlighting issues like lack of encapsulation, read-only enforcement challenges, and limited flexibility for future changes. It recommends using methods or collections as alternatives, despite performance benchmarks indicating that array properties are more efficient, ultimately suggesting adherence to Microsoft's guidelines.

Collection Performance: Finding First or Last and Count

Many developers use LINQ methods such as First(), Last(), and Count() to interact with collections. However, these methods can be about 2.33× slower in performance compared to direct indexing. Caution is advised when using indexing to avoid exceptions, and consideration should be given to code readability versus performance.

Collection Performance: Harnessing AsSpan() for Byte Array Conversion

When working with byte arrays, converting to Span can be achieved through AsSpan(). This method offers performance optimization by providing direct access without creating new arrays, efficient memory management, improved code clarity, and future-proofing for .NET framework evolution. Benchmark results show AsSpan() to be twice as performant with minimal memory allocations.

String Performance: Retrieving a Substring

The post discusses optimizing string concatenation in .NET by using the Span type, which significantly enhances performance and reduces memory allocation.

Collection Performance: Adding Items To a Dictionary

The excerpt from "Rock Your Code" discusses two methods for adding items to a Dictionary in .NET: Add() and TryAdd().

Collection Performance: The Fastest Way To Iterate Over a Collection in .NET!

Discover the quickest method to iterate over a collection in Microsoft.NET with this article, which includes performance benchmark tests.

Rock Your Code: Coding Standards for Microsoft .NET (8th Edition)

The 8th edition of the book, Rock Your Code: Coding Standards for Microsoft .NET, is available on Amazon. It consolidates Microsoft .NET coding standards and provides supplementary directives. Drawing insights from Microsoft’s code inspection tools, the book covers topics such as project setup, naming standards, class design, coding style, and more. The book's purpose is to facilitate superior code quality and swift integration of new team members. It's designed for use with Visual Studio 2022, C#, and .NET 8.

Nullable Type Performance: Retrieving a Nullable Value

The article discusses performance for the three methods for retrieving nullable values in C#, including using the nullable modifier '?' with HasValue and Value properties, the null coalescing operator ??, and the GetValueOrDefault() method.