I have a string "I want to learn "c#"". How can I include the quotes before and after c#?
' You can put a backslash character followed by a quote ( \" or \' ). This is called an escape sequence and Python will remove the backslash, and put just the quote in the string.
To put quotation marks in a string in Java, use the backslash escape character before the quotation mark like so: \" .
To enclose a quotation within a quotation, use… Place other punctuation (colons, semi-colons, question marks, etc.)… *Place other punctuation inside quotation marks when that punctuation is part of what is being quoted, such as a quoted question.
The first method to print the double quotes with the string uses an escape sequence, which is a backslash ( \ ) with a character. It is sometimes also called an escape character. Our goal is to insert double quotes at the starting and the ending point of our String.
Escape them with backslashes.
"I want to learn \"C#\""
As well as escaping quotes with backslashes, also see SO question 2911073 which explains how you could alternatively use double-quoting in a @-prefixed string:
string msg = @"I want to learn ""c#""";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With