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 strings actually behave like value types. The String class cannot be inherited, so you can’t create a custom class derived from it. In addition, 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 does not edit the existing string; it instead creates a new instance of the String object that contains your edits. The CLR then stores such String objects in the heap and returns a reference to them. We ...
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