# String vs String Builder(C#)

## Strings in C\#

String is immutable in C# that would mean you couldn’t modify it after it is created. It creates a new object of string type in memory if you will perform any operation.

```
string str1 = "Welcome!";
// creates a new string instance
str1 += "Hello";
str1 += "World”;
```

## StringBuilder is mutable in C#.

&#x20;This means that if an operation is performed on the string, it will not create a new instance every time. With that, it will not create new space in memory, unlike Strings.

```
StringBuilder str1 = new StringBuilder("");
str1.Append("Welcome!");
str1.Append("Hello World!");
string str2 = str1.ToString();
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hsnaltan13.gitbook.io/object-oriented-programming/untitled.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
