<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc" -->

---
title: Top 6 Performance Tips when dealing with strings in C#...
description: Six benchmarked tips cover string performance in C# 12 / .NET 8: StringBuilder beats concatenation beyond ~5 strings (with a later edit noting...
canonical: https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Top 6 Performance Tips when dealing with strings in C# 12 and .NET 8 | daily.dev
og:description: Six benchmarked tips cover string performance in C# 12 / .NET 8: StringBuilder beats concatenation beyond ~5 strings (with a later edit noting...
og:url: https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc
og:image: https://api.daily.dev/og/posts/N3CfK5hHC.png
og:image:alt: Top 6 Performance Tips when dealing with strings in C# 12 and .NET 8
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Top 6 Performance Tips when dealing with strings in C# 12 and .NET 8

**[Code4IT](https://daily.dev/sources/code4it)** · 16 min read · 0 upvotes · 0 comments

## Summary

Six benchmarked tips cover string performance in C# 12 / .NET 8: StringBuilder beats concatenation beyond ~5 strings (with a later edit noting string.Concat(string[]) can beat StringBuilder); EndsWith(char) outperforms EndsWith(string); IsNullOrWhiteSpace is roughly 2x slower than IsNullOrEmpty but often necessary for correctness; ToLowerInvariant is the fastest casing method; OrdinalIgnoreCase is up to 12x faster than InvariantCultureIgnoreCase for comparisons; and System.Text.Json allocates about a third the memory of Newtonsoft.Json while being roughly 2x faster. All results use BenchmarkDotNet with Log10-scaled plots generated via chartbenchmark.net.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/blog/top-6-string-performance-tips>

## Questions this post answers

### Is StringBuilder always faster than string concatenation in C#?

No, only beyond roughly 5 or 6 concatenations. Benchmarks on .NET 8 show plain string concatenation with the + operator is faster and allocates less for 4 strings, but StringBuilder becomes dramatically faster as the count grows, being about 7000 times faster than concatenation at 100,000 strings. A later addition noted string.Concat(string[]) can outperform StringBuilder too.

_Developers tuning hot loops can track benchmarked C# string tips like this on daily.dev._

### Is EndsWith with a char faster than EndsWith with a string in C#?

Yes, EndsWith(char) is consistently faster than EndsWith(string) in .NET 8 benchmarks, with the gap reaching roughly 10x at 10,000-item arrays and about 3.5x at 1,000,000 items. The same performance difference applies to StartsWith overloads, since comparing a single character avoids the overhead of string comparison logic.

_Anyone squeezing extra speed from .NET string checks can follow these comparisons on daily.dev._

### Is StringComparison.OrdinalIgnoreCase faster than InvariantCultureIgnoreCase in C#?

Yes, OrdinalIgnoreCase is significantly faster, measured at about 12 times faster than InvariantCultureIgnoreCase when comparing 100,000 strings and nearly 9 times faster at 1,000,000 strings in .NET 8 benchmarks. The difference exists because InvariantCultureIgnoreCase checks linguistic equivalence (so strings with embedded null characters can be considered equal), while OrdinalIgnoreCase compares exact character values.

_Picking the right string comparison mode for performance-sensitive code is easier with benchmarks like this on daily.dev._

## Similar posts on daily.dev

- [C\# String Comparison: Equals, OrdinalIgnoreCase, StringComparer, and Culture Pitfalls](https://daily.dev/posts/c-string-comparison-equals-ordinalignorecase-stringcomparer-and-culture-pitfalls-na8wbs2pq) · We Are .NET · 0 upvotes · 0 comments

---

Tags: [#performance](https://daily.dev/tags/performance), [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Top 6 Performance Tips when dealing with strings in C# 12 and .NET 8","url":"https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc"},"datePublished":"2026-10-04T13:06:53.024Z","dateModified":"2026-10-04T13:14:27.386Z","description":"Six benchmarked tips cover string performance in C# 12 / .NET 8: StringBuilder beats concatenation beyond ~5 strings (with a later edit noting...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ce7b6922e7df57461da2aa31861ed2da?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/ce7b6922e7df57461da2aa31861ed2da?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"performance,.net,c#","timeRequired":"PT16M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"Top 6 Performance Tips when dealing with strings in C# 12 and .NET 8"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/top-6-performance-tips-when-dealing-with-strings-in-c-12-and-net-8-n3cfk5hhc#faq","mainEntity":[{"@type":"Question","name":"Is StringBuilder always faster than string concatenation in C#?","acceptedAnswer":{"@type":"Answer","text":"No, only beyond roughly 5 or 6 concatenations. Benchmarks on .NET 8 show plain string concatenation with the + operator is faster and allocates less for 4 strings, but StringBuilder becomes dramatically faster as the count grows, being about 7000 times faster than concatenation at 100,000 strings. A later addition noted string.Concat(string[]) can outperform StringBuilder too. Developers tuning hot loops can track benchmarked C# string tips like this on daily.dev."}},{"@type":"Question","name":"Is EndsWith with a char faster than EndsWith with a string in C#?","acceptedAnswer":{"@type":"Answer","text":"Yes, EndsWith(char) is consistently faster than EndsWith(string) in .NET 8 benchmarks, with the gap reaching roughly 10x at 10,000-item arrays and about 3.5x at 1,000,000 items. The same performance difference applies to StartsWith overloads, since comparing a single character avoids the overhead of string comparison logic. Anyone squeezing extra speed from .NET string checks can follow these comparisons on daily.dev."}},{"@type":"Question","name":"Is StringComparison.OrdinalIgnoreCase faster than InvariantCultureIgnoreCase in C#?","acceptedAnswer":{"@type":"Answer","text":"Yes, OrdinalIgnoreCase is significantly faster, measured at about 12 times faster than InvariantCultureIgnoreCase when comparing 100,000 strings and nearly 9 times faster at 1,000,000 strings in .NET 8 benchmarks. The difference exists because InvariantCultureIgnoreCase checks linguistic equivalence (so strings with embedded null characters can be considered equal), while OrdinalIgnoreCase compares exact character values. Picking the right string comparison mode for performance-sensitive code is easier with benchmarks like this on daily.dev."}}]}
```

