Question

Is there is a way to escape embedded double quotes in a verbatim string in C#?

I have a lengthy string literal that wraps several lines. Escaping the quotes with a back-slash \ (at the bottom) does not work.

var message = @"
Hello {user-name},

This is to let you know that your order has shipped. 
Your order # is {order-number}.
The expected arrival date is {arrival-date}.

Thank you,
\"The BBQ Store\"";
1 Answers

With verbatim string you use an extra double quote, i.e. "".

So in your example do this:

var message = @"
Hello {user-name},

This is to let you know that your order has shipped. 
Your order # is {order-number}.
The expected arrival date is {arrival-date}.

Thank you,
""The BBQ Store""";

That will do the trick! Good luck.