How to add Double quotes in String in C#?


This is very simple thing, but as I am new to C# I would like to know, how can I add double quotes ("Hello " this is string") in string in C# programming.


Asked by:- jaiprakash
0
: 958 At:- 11/15/2022 3:31:33 PM
C# Double-quotes-add







1 Answers
profileImage Answered by:- vikas_jk

You can simply escape the double quotes using extra "

var str1 = @"""String Inside quotes""";
var str2 = "\"Second string Inside quotes\"";

Console.WriteLine(str1);
Console.WriteLine(str2);

Output:

"String Inside quotes"
"Second string Inside quotes"

OR

To make it look simpler

var str1 = @"String ""inside"" Then After";

That should work, thanks.

1
At:- 11/15/2022 3:50:34 PM
Thanks for helping, it works as needed. 0
By : jaiprakash - at :- 11/15/2022 3:51:22 PM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use