UNEXPECTED 87% Performance Boost! - C# Collection Initializers
April 8, 2024
• 1,990 views
benchmarkdotnetmicrosoft mvpperformance profilingbenchmarkdotnet tutorialdotnet performancesoftware performance.net performancebenchmarking .netoptimization techniquesbenchmarkingbenchmark dotnethow to use benchmarkdotnetbenchmarkdotnet how to usebenchmarkdotnet setupmeasuring performancec# new featuresc# collection expressionsC# collection expressionscollection expressionsdotnetcollection initializersprogrammingwhats new in c#C#.net
In C#, we have multiple ways that we can create collections. We have collection initializers in C# as well as collection expressions in C# - both of which create new collections with items in them.
But have you ever wondered about the performance of these two? Let's use BenchmarkDotNet to performance profile our C# code and see if collection expressions have different behavior!
