Mert Özen Further With Every Line

Blog

Mert Özen's blog posts on software development, backend, frontend, and DevOps.

Series
10 posts found #collections
C# 13–14 and .NET 9–10: OrderedDictionary, params Collections and More
Backend PART 11

C# 13–14 and .NET 9–10: OrderedDictionary, params Collections and More

Why Dictionary promises no order and .NET 9's generic OrderedDictionary, .NET 10's index-returning TryAdd/TryGetValue, PriorityQueue.Remove, allocation-free alternate lookup, C# 13 params collections and C# 14 extension members and span conversions.

7 Nov 2026 11 min 5
C# 11–12 and .NET 7–8: Generic Math, Frozen and Collection Expressions
Backend PART 10

C# 11–12 and .NET 7–8: Generic Math, Frozen and Collection Expressions

The generic sum you couldn't write in C# 10, generic math with static abstract members and INumber<T>; FrozenDictionary and FrozenSet, built once and read many times, measured with BenchmarkDotNet; square-bracket collection expressions, spread and CollectionBuilder.

7 Nov 2026 12 min 6
Generic Variance in C#: Covariance and Contravariance (in and out)
Backend PART 09

Generic Variance in C#: Covariance and Contravariance (in and out)

Why can't a List<EBook> be a List<Book> when it can be an IEnumerable<Book>? The hole in array covariance, covariance with out, contravariance with in, variance in delegates, the limits of the rules and the cast trap CS0266 suggests.

7 Nov 2026 10 min 7
Immutable Collections in C# and Choosing the Right Collection
Backend PART 08

Immutable Collections in C# and Choosing the Right Collection

The difference between a read-only view and real immutability, structural sharing in ImmutableList, builders, ImmutableArray versus ImmutableList measured with BenchmarkDotNet, and choosing the right collection with a complexity map.

7 Nov 2026 11 min 7
C# Collection Interfaces: IEnumerable, ICollection, IList and yield return
Backend PART 07

C# Collection Interfaces: IEnumerable, ICollection, IList and yield return

What IEnumerable, ICollection, IList and the IReadOnly* interfaces promise and what they don't; why an array throws on Add, exposing an internal list safely, choosing parameter types and writing lazy iterators with yield return.

7 Nov 2026 11 min 7
Sorted Collections in C#: SortedList, SortedDictionary, SortedSet and IComparer
Backend PART 06

Sorted Collections in C#: SortedList, SortedDictionary, SortedSet and IComparer

A book silently lost from a SortedSet when the comparer returns zero, and the tie-breaking second criterion. SortedDictionary on a red-black tree, SortedList with two sorted arrays and when to pick which; Min, Max and the live GetViewBetween on SortedSet; IComparer, culture-sensitive string order and broken comparer traps.

7 Nov 2026 8 min 7
C# Queue, Stack, LinkedList and PriorityQueue: Collections That Work in Order
Backend PART 05

C# Queue, Stack, LinkedList and PriorityQueue: Collections That Work in Order

Queue<T> for FIFO, Stack<T> for LIFO and undo, LinkedList<T> for O(1) inserts and removals through nodes, and a small LRU cache built from LinkedList and Dictionary. The .NET 6 PriorityQueue: why UnorderedItems is unordered, why it is not stable for equal priorities, a fair queue with sequence numbers, and the N most expensive books with EnqueueDequeue.

7 Nov 2026 8 min 10
C# Dictionary and HashSet: TryGetValue, Key Equality and Comparers
Backend PART 04

C# Dictionary and HashSet: TryGetValue, Key Equality and Comparers

How a Dictionary finds a key with GetHashCode and Equals, and why a class key without equality bloats it. The differences between Add, the indexer, TryAdd and TryGetValue, counting in a single lookup with .NET 6 CollectionsMarshal, the mutable key trap, OrdinalIgnoreCase and the Turkish I trap, ordering, and HashSet set operations.

7 Nov 2026 8 min 5
A Guide to C# List<T>: Adding, Removing, Capacity, Sorting and Searching
Backend PART 03

A Guide to C# List<T>: Adding, Removing, Capacity, Sorting and Searching

Elements skipped while removing in a loop, the 'Collection was modified' error and removing correctly with RemoveAll. The array inside, Capacity growing 4-8-16-32 and EnsureCapacity; Add, Insert, Remove and equality, the Find family, Sort, BinarySearch and why Sort is not stable.

7 Nov 2026 9 min 8
Why C# Has Generics: ArrayList, Boxing and Type Safety
Backend PART 01

Why C# Has Generics: ArrayList, Boxing and Type Safety

The price of ArrayList storing everything as object: InvalidCastException pushed to run time, boxing of value types and eight times the memory. Type safety with List<T>, how the runtime sees generic types, and bringing old collections into the generic world with OfType and Cast.

7 Nov 2026 8 min 8
Blog Map