Collections search
During interviews, we often hear — or say ourselves — that searching in an array is slower than in a hashtable. Some might even recall that array search has linear complexity, or O(n), while a hash table has constant complexity, O(1). But does this hold true in practice? What if there are situations where searching in an array turns out to be faster? Let's not rush to conclusions.
Collection initializer: List<T>
We're all used to write new List<int> { 1, 2, 3, 4 } or new int[] { 1, 2, 3, 4} to initialize collections with
values. Syntactically, they look similar, but the behavior is different, and you should be careful if you are worried
about
performance.
Any() vs Count: part 2
In Part 1, we compared Any() and Count methods for different collections and proposed optimization approaches.
Csharp (22)
.net (20)
performance (9)
benchmark (9)
LINQ (8)
collections (4)
.net6 (3)
.net8 (3)
.net48 (3)
.netcore31 (3)
MSSQL (3)
.net10 (2)
list (2)
.net9 (2)
string (2)
TSQL (2)
patterns (2)
stackoverflow (2)
HashSet (1)
dapper (1)
sql (1)
regex (1)
.net5 (1)
optimization (1)
roslyn (1)
analyzer (1)
NDepend (1)
asp.net (1)
.net471 (1)
specification (1)
repository (1)
EntityFramework (1)
xml (1)
soap (1)
CancellationToken (1)
Timer (1)
debug (1)
properties (1)
IEnumerable (1)
foreach (1)
retry (1)
circuit breaker (1)