Browse by Topic

Popular

Latest

Latest C# Posts

Illustration comparing a stack of plates (LIFO) and a queue of people (FIFO) with arrows showing order of processing
C#

C# Stack vs Queue: Choosing the Right Collection

Understand the core differences between Stack and Queue in C#, including LIFO vs FIFO behavior, typical operations, performance, and when to use each.

C#StackQueueData Structures
Illustration of a stack data structure with a TryPeek operation returning a boolean and the top element.
C#

C# Stack.TryPeek: Safe Peek Without Exceptions

Learn how C# Stack<T>.TryPeek inspects the top element without throwing on an empty stack, with code examples and edge cases.

C#Stack.NETCollections
Illustration of a C# stack with TryPop returning a value instead of throwing an exception on an empty stack.
C#

Using Stack<T>.TryPop in C#

Learn how Stack<T>.TryPop avoids exceptions on empty stacks in C#, when to use it instead of Pop, and how ConcurrentStack<T> handles thread safety.

C#Stack<T>TryPop.NET Collections
Illustration of a stack data structure with a pointer to the top element being inspected without removal.
C#

C# Stack Peek: Inspect the Top Element Without Removing It

Learn how to use C# Stack<T>.Peek to inspect the top element without removing it, including empty stack handling, TryPeek, and performance.

C#Stack<T>PeekCollections
Illustration of a C# stack with push and pop operations showing LIFO order
C#

C# Stack Push and Pop: Practical Usage

Learn how to use Stack<T> in C# for LIFO operations. Understand Push, Pop, Peek, TryPop, performance, and common pitfalls with practical examples.

C#Stack<T>CollectionsLIFO
Illustration of a call stack with value types and stackalloc buffer in C#
C#

C# Stack Usage: Allocation, Performance, and Limits

Understand C# stack usage: call stack frames, value-type allocation, and using stackalloc safely for short-lived buffers.

stack allocationvalue typesstackallocmemory management
Illustration of a C# generic Queue<T> with FIFO order, showing Enqueue and Dequeue operations.
C#

C# Generic Queue: FIFO Operations and Performance

c# generic queue: Learn how to use C# generic Queue<T> for FIFO processing, including Enqueue, Dequeue, Peek, performance behavior, and thread-safety considerations.

Queue<T>FIFOCollectionsConcurrency
Illustration comparing C# Queue and Stack data structures with FIFO and LIFO order.
C#

C# Queue vs Stack: Choosing the Right Collection

Learn the differences between C# Queue<T> and Stack<T>, when to use each, and how FIFO/LIFO behavior affects your code.

C# collectionsQueue<T>Stack<T>Data structures
Illustration of a queue data structure with a magnifying glass over the first element, representing TryPeek inspection.
C#

Using Queue<T>.TryPeek in C# to Inspect Items Safely

Learn how Queue<T>.TryPeek works in C#, how it differs from Peek, and how to safely inspect queue items without removing them.

C#Queue<T>TryPeekCollections
Illustration of a C# Queue with TryDequeue returning a boolean and an out parameter.
C#

C# Queue.TryDequeue: Safe Dequeue Without Exceptions

Learn how to use Queue<T>.TryDequeue in C# to safely dequeue items, handle empty queues without exceptions, and apply the same approach with ConcurrentQueue<T> in multithreaded code.

QueueTryDequeueConcurrentQueueException Handling