Information Technology Reference
In-Depth Information
String Literals
String literals use double quote marks rather than the single quote marks used in character lit-
erals. There are two types of string literals:
￿
Regular string literals
￿
Verbatim string literals
A regular string literal consists of a sequence of characters between a set of double quotes.
A regular string literal can include the following:
￿Characters
￿
Simple escape sequences
￿
Hex and Unicode escape sequences
Here's an example:
string st1 = "Hi there!";
string st2 = "Val1\t5, Val2\t10";
string st3 = "Add\x000ASome\u0007Interest";
The verbatim string literal differs from a regular string literal in that escape sequences are
not evaluated.
￿
A verbatim string literal is written like a regular string literal, but is prefaced with an @
character.
￿
Everything between the set of double quotes—including what would normally be con-
sidered escape sequences—is printed exactly as it is listed in the string.
￿
The only exception is sets of contiguous double quotes, which are interpreted as a single
double quote character.
Search WWH ::




Custom Search