Collection Performance: Leveraging LINQ MAXBy() and MINBy() for Efficient and Readable Code

The article explores the usage of LINQ's MinBy() and MaxBy() methods, which efficiently return the objects with the minimum and maximum values in a sequence based on a specified key selector function.

Rock Your Code: Code & App Performance for Microsoft .NET (4th Edition)

"Rock Your Code: Code & App Performance for Microsoft .NET" is a comprehensive guide that emphasizes the importance of optimizing code performance for enhanced user experience and backend efficiency. With practical insights and example code, developers learn essential practices for maximizing the performance of their business applications within the Microsoft .NET framework. From string manipulation to leveraging source generators, this edition covers a wide range of topics, including new chapters on code analysis and benchmark testing. Written for developers using Microsoft .NET 8 and Visual Studio 2022, this book offers timeless principles applicable across different versions of .NET, ensuring relevance and utility in any environment.

General Performance Tip: Choosing Between Conditional Statements – If, Switch, and Switch Expression Performance in C#

This article compares the performance of conditional if statements, switch statements, and switch expressions in C# code, with a focus on data retrieval.

Code It Any Way You Want: Performance Impact of Sealing Attributes

The excerpt discusses the recommendation to seal classes in .NET for design clarity and adherence to OOP principles, while noting that benchmark tests reveal non-sealed classes perform slightly better. Despite this, the author maintains sealing classes not meant for inheritance is essential for robust class design. An EditorConfig setup for checking this is also mentioned.

General Performance Tip: Optimizing Enum Value Name Retrieval

The article delves into the optimization of Enum value name retrieval in .NET, comparing three approaches. It demonstrates that one of these methods is 16.13 times more efficient, with no memory allocation.

Collection Performance: Is LINQ Always the Most Performant Choice?

The article explores the performance implications of using LINQ for collection queries, finding that a conventional foreach() loop outperforms LINQ by 1.75 times in identifying items matching a given query. The conclusion suggests benchmarking to determine the optimal approach based on the nature of the query and elements being sought.

Code It Any Way You Want: Comparison of Passing Parameters in Methods

This article explores different methods of passing parameters into methods, including conventional, in operator, and ref readonly approaches, comparing their performance. Despite differences in syntax, benchmark results demonstrate similar performance among these methods.

Code It Any Way You Want: Optimal Parameter Passing – Array vs. Params Keyword

The article explores the performance differences between passing parameters as arrays or using the params keyword in C#. Despite similarities in speed, the author recommends using the params keyword for its ease of use during function calls.

Collection Performance: Creating a List<> Using The Task.Parallel Library

The post discusses alternative approaches to adding items to a collection using For() or ForEach() from the Task Parallel Library.

General Performance Tip: Can Pattern Matching Improve Performance?

The article discusses the potential performance improvements gained by leveraging pattern matching in .NET. It contrasts a traditional method for rounding numbers with a more refined version employing pattern matching.