How to use double quotes in a string when using the @ symbol?

19,280

Solution 1

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""}");

Solution 2

I believe this should work:

string myString = @"Here is my ""quoted"" text.";
Share:
19,280
Paul Fryer
Author by

Paul Fryer

Updated on June 03, 2022

Comments

  • Paul Fryer
    Paul Fryer almost 2 years

    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