Choosing Between ValueTask and Task in C# for Efficient Async Performance
Selecting the right async primitive—ValueTask or Task—can reduce heap allocations and improve throughput in high‑frequency C# code.
ReadMeFeed / Community knowledge
Real questions. Useful conversations. Find the people who know your stack.
Selecting the right async primitive—ValueTask or Task—can reduce heap allocations and improve throughput in high‑frequency C# code.
Async streams let C# methods return sequences that are produced asynchronously. This guide explains how to declare, consume, and debug <code>IAsyncEnumerable<T></code>, covering common pitfalls and best practices.
C# records provide value equality and init-only properties that make them suitable for DTOs and domain models at trust boundaries. This architecture note covers the minimal design, validation patterns, shallow immutability limits, and when to switch to entity semantics.
Replace inefficient polling with Cosmos DB's change feed: ordered per-partition events, automatic scaling via the Change Feed Processor, and a C# worked example. Key limitation: deletes require soft-delete or tombstone patterns.
NullReferenceException remains common because reference types were nullable by default. Enabling nullable reference types in C# shifts null checks to compile time, with adoption patterns, a worked DTO example, and trade‑offs for .NET teams.
Extract an interface from a C# class in JetBrains Rider using Refactor This, then verify with dotnet build.
Substring() copies data to the heap. ReadOnlySpan<T> gives you a view into the original buffer instead. Here is how that changes parsing loops, where it stops working, and how to verify the difference.
Learn how to turn Cosmos DB into an event source by enabling the Change Feed, setting up a lease container, and using the Change Feed Processor Library in C#. The guide covers configuration, validation, monitoring, and fallback strategies for reliable event handling.
Use ReadOnlySpan<char> to slice strings without heap allocations. Learn ref struct limits and a parsing example.