This article explores the historical belief that sealed and internal classes in .NET might offer performance advantages, but suggests that in modern .NET runtimes, compiler optimizations, and hardware advancements, the difference in performance is likely negligible, emphasizing that design considerations should drive decisions regarding class sealing or internalization rather than performance concerns.
Category: .NET
Collection Performance: Optimizing Sequence Comparison
The article discusses different methods for comparing two collections for identity in programming. It introduces the use of the SequenceEqual() method for comparing sequences in the LINQ extension methods, as well as the StructuralSequenceEqual() method, which is beneficial for comparing custom classes based on the values of their elements rather than object references.
General Performance Tip: Type Conversion
This article explores type conversion in programming, comparing the traditional syntax with the newer "as" keyword in .NET. While the "as" keyword improves code readability, benchmark results suggest that the conventional method is slightly more performant, advising developers to stick with traditional type conversion unless significant performance improvements are observed with the "as" keyword.
Reference Type & Structure Performance: Constant vs. Read-only Property
This content discusses the performance of using a constant vs. a read-only property.
String Performance: Checking for a Character
The article compares two methods of checking for the presence of a specific character in a string in C#.
Code It Any Way You Want: Constants vs. Properties
The post discusses the importance of using constants for static numerical or string values in code, highlighting benefits such as clarity of intent. It provides an example of a read-only property for π and notes that .NET 10 benchmarks show similar performance for both methods. EditorConfig settings for identifying issues are also mentioned.
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.
Coding Faster with dotNetTips.com Spargine 8: May 2024 Release
Spargine 8 (v2024.8.5.1) was released on May 5th, 2024, offering NuGet packages for .NET 8. This update includes new methods, benchmarks, and unit tests, integrating speed enhancements informed by benchmark tests outlined in the 4th edition of Rock Your Code. Notably, it introduces the CopyFile method in the FileHelper class and performance improvements in various methods. You can find the performance data on GitHub. Contributing to these projects is encouraged. Check out the GitHub release page for more information.
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.

You must be logged in to post a comment.