Collection Performance: Is LINQ Always the Most Performant Choice?
DotNetTips Blog
by dotNetDave
55m ago
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 ..read more
Visit website
Code It Any Way You Want: Comparison of Passing Parameters in Methods
DotNetTips Blog
by dotNetDave
55m ago
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 ..read more
Visit website
General Performance Tip: Can Pattern Matching Improve Performance?
DotNetTips Blog
by dotNetDave
55m ago
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 ..read more
Visit website
General Performance: Choosing Between GetValueOrDefault() and Coalesce Operator for Nullable Integers
DotNetTips Blog
by dotNetDave
2d ago
In dealing with nullable integers and the need for default values, two common approaches are the coalesce operator (??) and GetValueOrDefault(). Alternatively, utilizing HasValue with the conditional operator is demonstrated ..read more
Visit website
Code It Any Way You Want: Optimal Parameter Passing – Array vs. Params Keyword
DotNetTips Blog
by dotNetDave
2d ago
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 ..read more
Visit website
Collection Performance: Creating a List<> Using The Task.Parallel Library
DotNetTips Blog
by dotNetDave
4d ago
The post discusses alternative approaches to adding items to a collection using For() or ForEach() from the Task Parallel Library ..read more
Visit website
String Performance: Appending a Character using the StringBuilder
DotNetTips Blog
by dotNetDave
1w ago
The use of a single character with a StringBuilder from an ObjectPool can improve performance. Benchmark results show similar overall performance, but without an ObjectPool, using a character becomes more significant. It is recommended to use a character in such cases. EditorConfig setup can check for this issue using dotnet_diagnostic.CA1834.severity = warning ..read more
Visit website
Code It Any Way You Want: Checking Strings for Null
DotNetTips Blog
by dotNetDave
1w ago
The article discusses best practices for checking strings for null in coding. It outlines three common methods: using == null, is null, or string.IsNullOrEmpty ..read more
Visit website
General Performance Tips
DotNetTips Blog
by dotNetDave
1w ago
These articles delves into indispensable tips that should consistently be integrated into your coding practices. Though these tips may seem small, their cumulative impact becomes pronounced, particularly when handling high message volumes. Embracing these fundamental practices can yield substantial benefits for overall performance ..read more
Visit website
Reference Type & Structure Performance: Hashing Classes, Records, and Structures
DotNetTips Blog
by dotNetDave
1w ago
A SHA256 hash can be generated for a class, record, or structure using a specific code. Performance analysis shows that hashing a class is 1.032 times faster than a structure and 1.048 times more efficient than a record. The memory allocations for record, reference, and value types are also provided in bytes ..read more
Visit website

Follow DotNetTips Blog on FeedSpot

Continue with Google
Continue with Apple
OR