.net, C# and programming

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.


Harmful collection transformations. Part 2: automatic diagnostics

The previous post contains code examples that can be simplified by removing ToArray() or ToCharArray() calls. And an interesting example with List<char> constructor. But we need to be very attentive to find such places in our code. It would be much safer to do it automatically. This post shows us about automatic compiler diagnostics that can detect issues.