mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 17:41:41 +00:00
clarify use case for verbatim strings
added example for using @ symbol with strings
This commit is contained in:
parent
7c2bd365bd
commit
b01b53a46d
@ -132,6 +132,12 @@ namespace Learning.CSharp
|
|||||||
DateTime fooDate = DateTime.Now;
|
DateTime fooDate = DateTime.Now;
|
||||||
Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy"));
|
Console.WriteLine(fooDate.ToString("hh:mm, dd MMM yyyy"));
|
||||||
|
|
||||||
|
// Verbatim String
|
||||||
|
// You can use the @ symbol before a string literal to escape all characters in the string
|
||||||
|
string path = "C:\\Users\\User\\Desktop";
|
||||||
|
string verbatimPath = "C:\Users\User\Desktop";
|
||||||
|
Console.WriteLine(path == verbatimPath); // => true
|
||||||
|
|
||||||
// You can split a string over two lines with the @ symbol. To escape " use ""
|
// You can split a string over two lines with the @ symbol. To escape " use ""
|
||||||
string bazString = @"Here's some stuff
|
string bazString = @"Here's some stuff
|
||||||
on a new line! ""Wow!"", the masses cried";
|
on a new line! ""Wow!"", the masses cried";
|
||||||
|
Loading…
Reference in New Issue
Block a user