14

I need to use double quotes in a string that uses the @ symbol. Using double quotes is breaking the string. I tried escaping with \, but that doesn't work. Ideas?

alt text

Paul Fryer
  • 9,268
  • 14
  • 61
  • 93
  • Same as [ In C#, can I escape a double quote in a literal string? ](http://stackoverflow.com/questions/1928909/in-c-can-i-escape-a-double-quote-in-a-literal-string). – Matthew Flaschen Sep 04 '10 at 00:26

3 Answers3

25

I believe this should work:

string myString = @"Here is my ""quoted"" text.";
Patrick
  • 971
  • 9
  • 17
15

You double the quotes inside a verbatim string to get a quote character.

This makes your given sample:

(@"PREFIX rdfs: <" + rdfs + @">
      SELECT ?s ?p ?o
        WHERE { ?s ?p rdfs:Literal }
              {?s rdfs:label ""date""}");
GBegen
  • 6,107
  • 3
  • 31
  • 52
0

You can use this if you want to write into a file :

string myString = @"Here is my ""quoted""text.";
myString.Replace(@"""",@"&quot;");
Cb_M
  • 197
  • 1
  • 2
  • 10