13.2. Strings As Objects

In Chapter 1, we introduced a number of predefined C# types, including the string type. What we hinted at, but didn't make explicitly clear at the time, is that strings are objects. We went over some of the basics of creating and using strings in Chapter 1; we'll now review some of what we discussed before, as well as provide additional insights about strings' object nature in this section.

13.2.1. The "string" Alias

The keyword string is really an alias for the String class defined in the System namespace. When we declare a string variable and assign it a value, as follows:

string name = "Jackson";

we're actually instantiating an object/instance of the System.String class and initializing the object with the string ...

Get Beginning C# 2008 Objects: From Concept to Code 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.