Инициализатор коллекций: List<T>
Мы все привыкли писать new List<int> { 1, 2, 3, 4 }
или new int[] { 1, 2, 3, 4}
, чтобы инициализировать коллекции какими-то значениями. Синтаксически это выглядит похоже, но поведение отличается, и вам следует быть осторожными, если вы заботитесь о производительности.
List initializer
We all used to type new List<int> { 1, 2, 3, 4 }
or new int[] { 1, 2, 3, 4}
to initialize collections with some values. It looks similar in syntax but differs in behavior, and you should be careful if you are concerned about performance.
Harmful collection transformations. Part 3: collections
Starting with string
in the first post we continue to study examples with collection transformations and how they affect our applications.
Csharp (28)
.net (23)
LINQ (11)
performance (11)
benchmark (11)
MSSQL (7)
TSQL (5)
patterns (4)
.net48 (4)
.netcore31 (4)
.net6 (4)
.net9 (4)
collections (3)
string (3)
list (2)
dapper (2)
sql (2)
specification (2)
repository (2)
EntityFramework (2)
regex (2)
.net5 (2)
.net8 (2)
OPTIMIZATION (2)
.net471 (2)
stackoverflow (2)
retry (2)
circuit breaker (2)
paging (1)
roslyn (1)
analyzer (1)
NDepend (1)
asp.net (1)
xml (1)
soap (1)
CancellationToken (1)
Timer (1)
debug (1)
properties (1)
IEnumerable (1)
foreach (1)