3 ms·
Strings in C# are inmutable. To work with strings you should use StringBuilder.
by yeasku 1y ago
Strings in C# are inmutable.
To work with strings you should use StringBuilder.
- orphea 1y ago> Strings in C# are inmutable. Yes, but > To work with strings you should use StringBuilder. It helps combine strings together. The author needed the opposite - split/slice strings.
- kbolino 1y agoEric Lippert describes the difference between immutability and what he calls "persistence" and explains why C#/.NET copies the string contents to make a substring: https://stackoverflow.com/a/6750591/814422 https://stackoverflow.com/a/6750591/814422 Go's strings are also immutable and yet substrings share the same internal memory. Java/JVM also has immutable strings and yet substrings shared the char[] array of the parent string up until Java 7, when they switched to copying instead (for the same reason as .NET): https://mail.openjdk.org/pipermail/core-libs-dev/2012-June/010370.html https://mail.openjdk.org/pipermail/core-libs-dev/2012-June/0...
- yeasku 1y agoThat SO link is really good, thank you for the comment.