In the string, the dual quotation number allows them to include them without damage the grammar. This guide explains in detail the method of achieving this purpose in C#.
Method 1: Words of word -by -word string
The word -by -word string is allowed to contain dual quotes in the string without righteousness in the string. They use "@" as the prefix:
Method 2: Royal character
string verbatim = @"He said to me, ""Hello World"". How are you?";
or, you can use the back sloping bar character ('') to the dual quotation number:
<<> Comparison
string escaped = "He said to me, \"Hello World\". How are you?";
<示> Example
In your example:
The word -by -word string is retained in the double quotation marks in the string, and the method of the rigid character is transferred to it:
<:> Note:
@"He said to me, ""Hello World"". How are you?"
In any case, the generated string contains only one double quotation marks. The double quotes have been righteous. The righteousness ensures that the dual quotes are explained as part of the string, not the string termination symbol.
The above is the detailed content of How to Escape Double Quotes in C# Strings?. For more information, please follow other related articles on the PHP Chinese website!