CHAPTER 5

image

String

The string data type is used to store string constants, which are delimited by double quotes.

string a = "Hello";

String concatenation

The plus sign is used to combine two strings. It is known as the concatenation operator (+) in this context. It also has an accompanying assignment operator (+=), which appends a string to another and creates a new string.

string b = a + " World"; // Hello Worlda += " World";           // Hello World

Escape characters

A statement can be broken up across multiple lines, but a string constant must be on a single line. In order to divide it, the string constant has to first be split up using the ...

Get C# Quick Syntax Reference 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.