Chapter 8. Working with Strings

Within the .NET Framework base class library, the System.String type is the model citizen of how to create an immutable reference type that semantically acts like a value type.

String Overview

Instances of String are immutable in the sense that once you create them, you cannot change them. Although it may seem inefficient at first, this approach actually does make code more efficient. If you call the ICloneable.Clone method on a string, you get an instance that points to the same string data as the source. In fact, ICloneable.Clone simply returns a reference to this. This is entirely safe because the String public interface offers no way to modify the actual String data. Sure, you can subvert the system by employing ...

Get Accelerated C# 2010 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.