How to insert or add double quote in string in .net

Following example show that how to insert double quote (“) in string in and

we can put double quote in string in by using two double quote(“”).

Dim str As String = "Welcome ""Guest"""


string str = "Welcome " + "\"" + "Guest" + "\"";

The above string will be displayed as follows

Welcome “Guest”

From the above, in c# we are using character escape sequence. Basically, a Character consisting of a backslash (\) followed by a letter is called “escape sequence.” So when you need to add a single quote, double quote or a newline character in a string, you can use escape sequences. There is also an option that you use verbatim string(string followed by ‘@’) for these type of situations.

C# has many character escape sequences such of them are following:

\’ – single quote, needed for character literals
\” – double quote, needed for string literals
\\ – backslash
\b – Backspace (character 8)
\n – New line (character 10)
\r – Carriage return
\t – Horizontal tab
\v – Vertical quote