.NET version 8 introduced the FrozenSet type, offering immutable and hashable set collection with benefits including improved performance, memory efficiency, and thread safety. Benchmarks show comparable performance to List, outperforming HashSet and ImmutableHashSet. However, it is slightly slower than the latter in lookups. FrozenSet offers significant advantages for concurrent applications and memory optimization.
Category: C#
Collection Performance: Enhancing Dictionary Performance with FrozenDictionary
The FrozenDictionary is a thread-safe, immutable, read-only dictionary optimized for fast lookups. It outperforms the Dictionary, reducing iteration and lookup times significantly.
256 Seconds with dotNetDave: Handling Exceptions Part 1 – Reusable Assemblies
This content discusses exception handling in Microsoft .NET, focusing on application layer and reusable assemblies. It offers insights on preventing exceptions and notifying calling code, and references a related book. The principles are noted to be applicable to other programming languages.
Serializing Objects: Efficient Serialization and Deserialization of Collections with JsonSerializer
The article demonstrates the ease of serializing and deserializing collections using JsonSerializer.
Microsoft .NET Code Analysis: Eliminating Dictionary Double Lookups
Using ContainsKey() followed by an indexer on dictionaries results in a double lookup, decreasing performance. This is common anti-pattern. This article will show you how to fix this and increase performance up to 2x.
Optimizing Collection Examination: A Comparative Analysis of Predicate Methods in C#
The article explores four methods for examining items in a collection using predicates, with a focus on performance. A Twitter poll revealed that over 50% of developers favored the LINQ Any() method, prompting the author to verify its efficiency in comparison to other options like Count() and Exists().
Enhancing Enum Handling in Spargine: Beyond Enums and into Versatility
Enums are essential in programming for representing fixed constants, enhancing readability, and avoiding magic numbers. However, using them as database keys is discouraged due to performance issues. The article details Spargine’s EnumHelper and EnumExtensions for improved handling of Enums and introduces the Enumeration pattern for greater flexibility and functionality.
Code It Any Way You Want: Initializing Reference Type Static Fields Inline for Enhanced Code Readability
The article advocates for initializing reference type static fields inline to enhance code readability and prevent unexpected behavior caused by uninitialized static fields. Microsoft recommends initializing these fields at the point of declaration to improve clarity. The article provides examples demonstrating the issue and the recommended solution, emphasizing the use of static constructors for initialization.
Code It Any Way You Want: Expression-Bodied Methods vs. Traditional Methods
The article discusses the use of expression-bodied methods in .NET as an alternative to traditional methods for creating simple functions. It presents a comparison between the two methods in terms of syntax and performance. Despite the syntactical differences, benchmark results show that both methods demonstrate similar performance characteristics.
General Performance Tip: Retrieving the Nullable Value from a Reference Type
The article discusses two methods for retrieving nullable values from reference types in C#, showcasing examples using the ternary conditional expression and the null coalesce approach. Benchmark results indicate that the null coalesce approach demonstrates 1.12 times higher efficiency in performance compared to the ternary conditional expression.

You must be logged in to post a comment.