O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

9.7. The string type and string literals

There are two types of string literals in C#:

  • regular string literals;

  • verbatim string literals.

What we have seen and used so far are regular string literals. These consist of characters enclosed in double quotation marks and may contain escape sequences, hexadecimal (\x) and Unicode (\u) escape sequences within. Examples of regular string literals include the following:

  • "Hello!"

  • "My \tname is\nMok"

  • "Apple starts with the letter \u0041, Banana starts with the letter \x42"

Verbatim string literals are string literals which are 'what they seem'. If you include a @ sign in front of a string literal, everything between the double quotes will be considered part of the string 'as they are'. The @ symbol, in this ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required