The String Type

The built-in types we’ve seen so far are all value types. System.String, however, is a reference type. To understand why this is the case, we first need to know about the memory layout and its implications (the subject of Chapter 9, “Introducing Types,” which covers the heap and the stack).

Note: System.String Versus the string Reserved Word

Don’t forget that the C# reserved words for built-in types are simply aliases for the underlying BCL types. In the case of C#’s string, that is System.String. Both can be used in source code, and when the System namespace is imported, the latter one can be abbreviated to String, with a capital S.

This casing doesn’t change the characteristics of the type. String is, and always is, a reference ...

Get C# 5.0 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.