Working with Strings
Working with strings is one of the most common developer activities. In the .NET Common Type System, System.String is a reference type. This might be surprising, because actually strings behave like value types. Regarding this, there are a couple of things to say. First, the String class cannot be inherited, so you can’t create a custom class derived from it. Second, String objects are immutable like value types. What does this mean? It means that when you create a new String you cannot change it. Although you are allowed to edit a string’s content, behind the scenes the CLR will not edit the existing string; it will instead create a new instance of the String object containing your edits. The CLR then stores such String ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access