The String Type

The built-in types we’ve seen so far are all value types. System.String, on the other hand, 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, where we talk about the heap and the stack).

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

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