-3

I have this simple code:

var q = "this is a test";
return q.Length;

Just that sometimes I need to be able to insert string that contains double quotes and this yields those errors

var q = "this is "not" a test";

How can I avoid that without manually escaping chars? I need something like python has its triple quotes when you can include anything

q  = '''I can include 'everything' in here as long it's not triple quotes'''
user21616
  • 35
  • 7
  • @Amy this is not a duplicate of the post you mentioned. It's the opposite. – Koby Douek Mar 24 '17 at 16:15
  • Then pick your possible duplicate. Another possible dupe: https://stackoverflow.com/questions/1928909/can-i-escape-a-double-quote-in-a-verbatim-string-literal –  Mar 24 '17 at 16:16

1 Answers1

0

you can state a @ at the beginning of your string:

var q = @"this ""is"" how you do it.";
Koby Douek
  • 16,156
  • 19
  • 74
  • 103
  • Or to avoid double quoting, you can `escape` characters inside of strings as such: `var q = "this \"is\" how you do it` which will `Console.Write()` as `this is how you do it`. – James Gould Mar 24 '17 at 16:34
  • So that's what the @ stands for :) Thank you! – user21616 Apr 21 '17 at 17:16