Verbatim string literals

  • Thread starter Thread starter Mark Rae
  • Start date Start date
M

Mark Rae

Hi folks,

Apologies - am having a bit of a "senior moment"...

Is there a way to convert a string containing escaped characters into a
verbatim string literal?

I.e. converting something like

"This string contains \"double quotes\" and \'single quotes\'"

into

@"This string contains "double quotes" and 'single quotes'"

I had thought that Regex.Unescape did this, but it's not working for me this
morning...

Any assistance gratefully received.

Mark
 
Even in verbatim string literals, double quotes are not escaped. Within
verbatim strings, you need to escape double quotes with double quotes.
e.g.,
string test = @"abc""def";
--
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB.NET to C# Converter
Instant VB: C# to VB.NET Converter
Instant C++: C# to C++ Converter
Instant J#: VB.NET to J# Converter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top