| Start |
|---|
| Interpolated Verbatim Strings Verbatim strings can be combined with the new String interpolation (opens new window) features found in C#6. Output: Testing \n 1 2 3 Live Demo on .NET Fiddle (opens new window) As expected from a verbatim string, the backslashes are ignored as escape characters. And as expected from an interpolated string, any expression inside curly braces is evaluated before being inserted into the string at that position. |
| Escaping Double Quotes Double Quotes inside verbatim strings can be escaped by using 2 sequential double quotes Output: "I don't think so," he said. |
| Verbatim strings instruct the compiler to not use character escapes In a normal string, the backslash character is the escape character, which instructs the compiler to look at the next character(s) to determine the actual character in the string. (Full list of character escapes (opens new window)) In verbatim strings, there are no character escapes (except for This verbatim string Output: c:\temp\newfile.txt As opposed to using an ordinary (non-verbatim) string: that will output: using character escaping. (The |
Multiline Strings Output: This is a multiline paragraph Live Demo on .NET Fiddle (opens new window) Multi-line strings that contain double-quotes can also be escaped just as they were on a single line, because they are verbatim strings. Live Demo on .NET Fiddle (opens new window) It should be noted that the spaces/tabulations at the start of lines 2 and 3 here are actually present in the value of the variable; check this question (opens new window) for possible solutions. SyntaxRemarksTo concatenate string literals, use the @ symbol at the beginning of each string. |
Read Article
https://develop.horje.com/learn/1434/reference