This BenchmarkDotNet project compares the performance of string.Format(), string interpolation, and string concatenation in C#. It provides concrete benchmark data to answer the common question of which string formatting approach is fastest in .NET.
The project includes two benchmark classes: SimpleBenchmarks measures single concatenation performance at varying string lengths, while AppendInLoopBenchmarks tests loop scenarios and includes StringBuilder as a comparison baseline. Both benchmark classes test with parameter lengths of 1, 1,000, and 1,000,000 characters to show how performance scales with input size.
Built on .NET 8 with BenchmarkDotNet 0.13.11, this project gives developers real data to make informed decisions about string formatting in performance-sensitive C# code.
- .NET 8.0 SDK
cd StringFormatBenchmarks\StringFormatBenchmarks
dotnet run -c ReleaseIf you found this useful and you want to learn more about C#, .NET, and software engineering, subscribe to the free Dev Leader Weekly newsletter:
Subscribe to Dev Leader Weekly
- All Links
- Website - Dev Leader
- YouTube - Dev Leader
- YouTube - Dev Leader Path To Tech
- YouTube - Dev Leader Podcast
- YouTube - CodeCommute
- Newsletter - Dev Leader Weekly
- LinkedIn - Nick Cosentino
- GitHub - ncosentino
- Twitter/X - Dev Leader
- Threads - Dev Leader
- Bluesky - Dev Leader
- Mastodon - Dev Leader
- Facebook - Dev Leader
- TikTok - Dev Leader
- Twitch - Dev Leader
- Stack Overflow - Nick Cosentino
Powered by BrandGhost 👻