Question: Lot of questions has been already asked about the differences between string and string builder and most of the people suggest that string builder is faster than string. I am curious to know if string builder is too good so why string is there? Moreover, can some body give me an example where string will be more usefull than string builder?

Answer: 
It's not a case of which is more useful...

A `String` is a `String` - one or more characters next to each other. If you want to ***change*** a string in someway, it will simply create more strings because they are ***[immutable](https://csharpindepth.com/articles/Strings)***.

A `StringBuilder` is a class which creates strings. It provides a means of constructing them without creating lots of reduntant strings in memory. The end result will always be a `String`.

**Don't do this**

```
string s = "my string";
s += " is now a little longer";

```

**or**

```
s = s + " is now longer again";

```

That would create **5** strings in memory (in reality, see below).

Do this:

```
StringBuilder sb = new StringBuilder();
sb.Append("my string");
sb.Append(" is now a little longer");
sb.Append(" is now longer again");
string s = sb.ToString();

```

That would create **1** string in memory (again, see below).

You can do this:

```
string s = "It is now " + DateTime.Now + ".";

```

This only creates **1** string in memory.

As a side-note, creating a `StringBuilder` does take a certain amount of memory anyway. As a rough rule of thumb:

* Always use a `StringBuilder` if you're concatenating strings in a loop.
* Use a `StringBuilder` if you're concatenating a string more than 4 times.
A string is good because it is immutable. And that immutable is good, is something that functional languages are prove of.

Because if you have a (reference to) string "This is a string" you can be sure that it will have the same value forever. While the value of a StringBuilder might be changed (by a method call, another thread etc).

But, sometimes you need raw, pure speed and memory usage optimizations. In that case you use a stringbuilder.

An example:

```
 var a = "This is a string";
 var b = a;
 a += ". And some part is added";   // a now references another string in memory

 var aSB = new StringBuilder("This is a string");
 var bSB = aSB
 aSB.Append(". And some part is added"); // aSB and bSB still reference the same memory spot

 Console.WriteLine(b);   // ==> This is a string
 Console.WriteLine(bSB); // ==> This is a string. And some part is added

```