---
title: "What is the difference between string and StringBuilder, and when does it matter?"  
description: "What is the difference between string and StringBuilder, and when does it matter?"  
author: "Lea Hartmann"  
published: 2026-11-13  
updated: 2026-11-13  
canonical: https://www.mindstick.com/forum/163006/what-is-the-difference-between-string-and-stringbuilder-and-when-does-it-matter  
category: "C# and .NET"  
tags: ["c#", "StringBuilder", "string", "performance", "memory"]  
reading_time: 1 minute  

---

# What is the difference between string and StringBuilder, and when does it matter?

Everyone says never concatenate strings in a loop. Is StringBuilder always better than using +?

## Replies

### Reply by Ivan Nikolaev

A C# string cannot be changed after it is created. Every time you write `s = s + "x"`, a brand new string is allocated and the old one is thrown away. In a loop that runs thousands of times, this creates a lot of garbage and gets slow.

StringBuilder keeps an internal buffer and appends into it, so building a long string in a loop is much cheaper.

It does not matter in every case:

- Joining a few strings once is fine with +, string interpolation or string.Concat. The compiler optimises many of these.
- For a list of items, `string.Join(", ", items)` is clearer and fast.
- Use StringBuilder when you append in a loop or build large text, such as a report or CSV.

Do not rewrite readable code for a loop of ten items. Use StringBuilder where the loop is big.


---

Original Source: https://www.mindstick.com/forum/163006/what-is-the-difference-between-string-and-stringbuilder-and-when-does-it-matter

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
