Paul Fryer
Paul Fryer

Reputation: 9537

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

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

Upvotes: 14

Views: 20721

Answers (3)

Cb_M
Cb_M

Reputation: 317

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

string myString = @"Here is my ""quoted""text.";
myString.Replace(@"""",@""");

Upvotes: 0

GBegen
GBegen

Reputation: 6157

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

Upvotes: 15

Patrick
Patrick

Reputation: 991

I believe this should work:

string myString = @"Here is my ""quoted"" text.";

Upvotes: 25

Related Questions