1.7. Strings
We'll discuss one more important predefined type in this chapter: the string type.
NOTE
Just a reminder: unlike the other C# types introduced in this chapter, string isn't a value type; it's a reference type, as we mentioned earlier. For purposes of this introductory discussion of strings, this observation isn't important; the significance of the string type's being a reference type will be discussed in Chapter 13.
A string represents a sequence of Unicode characters. There are several ways to create and initialize a string variable. The easiest and most commonly used way is to declare a variable of type string and to assign the variable a value using a string literal, which is any text enclosed in double quotes:
string name = ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access