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 ...

Get Visual Basic® 2010 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.