Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 819
Paul Fryer Avatar asked Sep 04 '10 00:09

Paul Fryer


People also ask

How can I add double quotes to a string that is inside a variable?

Use a formatted string literal to add double quotes around a variable in Python, e.g. result = f'"{my_var}"' . Formatted string literals let us include variables inside of a string by prefixing the string with f .

How do you escape quotation marks in a string?

How to Escape Quotes in a String. To add quoted strings inside of strings, you need to escape the quotation marks. This happens by placing a backslash ( \ ) before the escaped character. In this case, place it in front of any quotation mark you want to escape.

What is the symbol of double quote?

The use of quotation marks, also called inverted commas, is very slightly complicated by the fact that there are two types: single quotes (` ') and double quotes (" ").


2 Answers

I believe this should work:

string myString = @"Here is my ""quoted"" text.";
like image 125
Patrick Avatar answered Oct 20 '22 08:10

Patrick


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""}");
like image 29
GBegen Avatar answered Oct 20 '22 06:10

GBegen