Skip to content

Strings

Mario Gutierrez edited this page Jan 7, 2017 · 2 revisions

Formatting

string.Format("{0} {1} {2}", a, b, c);

With format specification.

string.Format("{0:d9}", someNumber);

Verbatim Strings

With "verbatim" strings, no escaping is done (\n, \t, etc).

string v = @"This is a ""verbatim"" string. Backslashes, \, are not escaped.";

Interpolated Strings

.NET 4.6+

With "interpolated" strings, variables can be referenced in the string and filtered.

string p = $"myVariable has value {myVariable | expression}."
Clone this wiki locally