Browse by Topic

Popular

Latest

Latest C# Posts

Illustration of a C# array with a caret pointing to the last element, representing the index-from-end operator.
C#

C# Index Operator: Using ^ and ^.. Syntax

c# index operator: Learn how the C# index operator (^) and range operator (..) work, with practical examples for arrays, lists, and custom types.

C#index operatorrange operatorcollections
Illustration of a C# code snippet showing array slicing with the range operator, with a highlighted segment.
C#

Using the C# Range Operator

c# range operator: Learn how the C# range operator works for slicing arrays, strings, and collections, including syntax, edge cases, and performance considerations.

C# 8Range OperatorIndexArray Slicing
Illustration of a C# Memory<T> slice referencing a subrange of a data buffer without copying
C#

Using C# Memory Slice for Efficient Data Access

c# memory slice: Learn how to use Slice on Memory<T> and ReadOnlyMemory<T> in C# to share data ranges without copying or allocating new arrays.

Memory<T>Span<T>ArraySegment<T>ReadOnlyMemory<T>
Diagram contrasting Span<T> as a stack-only view and Memory<T> as a heap-allocated buffer, connected by a pipeline.
C#

C# Span vs Memory: Choosing the Right Type

c# span vs memory: Learn when to use Span<T> and when to use Memory<T> in C#. Understand stack-only constraints, async limitations, streaming scenarios, and practical...

Span<T>Memory<T>C# PerformanceStackalloc
Illustration comparing C# Memory and ReadOnlyMemory types, showing a mutable and an immutable view of the same data buffer.
C#

C# Memory vs ReadOnlyMemory: Choosing the Right Type

Understand the difference between Memory<T> and ReadOnlyMemory<T> in C#, when to use each, and how they relate to Span<T> for efficient buffer handling.

Memory<T>ReadOnlyMemory<T>C# performanceSpan<T>
A visual representation of a C# heap with managed objects and a magnifying glass analyzing allocation hotspots.
C#

C# Memory Usage: Diagnosing and Reducing Allocations

Practical techniques for profiling C# memory usage, reducing allocation hotspots, reusing buffers, and avoiding common GC traps.

memory managementGC pressurearray poolingperformance
Visual comparison of C# Memory and Span showing a safe managed reference versus a stack-like view.
C#

C# Memory vs Span: Choosing the Right Approach

c# memory vs span: Understand the differences between Memory<T> and Span<T> in C#, including when to use each, their runtime behavior, and practical guidance for high-...

C# Span<T>Memory<T>Memory ManagementPerformance
Iconic representation of a stack memory buffer with a C# Span pointer, symbolizing zero-allocation temporary buffers.
C#

Using C# Span with Stackalloc for Zero-Allocation Buffers

Learn how to use C# Span<T> with stackalloc for zero-allocation temporary buffers: syntax, constraints, practical examples, and when to avoid stack allocation.

Span<T>stackallocmemory managementperformance
Diagram of a stack frame with a stackalloc buffer shown in green, highlighting the brief lifetime of the allocated memory.
C#

Using C# stackalloc for High-Performance Buffers

Learn how to use c# stackalloc to allocate buffers on the stack, avoid heap allocations, and improve performance in high-frequency code paths.

C#stackallocSpan<T>memory management
Illustration of a C# Span slicing a byte array into segments without copying memory.
C#

Slicing Spans in C#

Learn how to use Span<T>.Slice to create memory views without allocations, with practical examples and performance considerations.

Span<T>C# performanceMemory managementSlicing