How can I add double quotes to a string that is inside a variable?
You need to escape them by doubling them (verbatim string literal):
string str = @"""How to add doublequotes""";
Or with a normal string literal you escape them with a \
:
string str = "\"How to add doublequotes\"";
Add double quotes to string which is stored in variable
var audioUrl = "\""+ data.url+ "\"";
Whatever your get audioUrl and you want to wrap it with ", you need to put them and escape inner ones with . Above will result in:
"http://xxxxx/xxx/xx-xx-123.m4a"
OR if you are using the single quotes then no need to use the escape character.
var audioUrl = '"'+ data.url+ '"';
How to add double quotes around a String variable in Java?
There are actually 2 issues with your code.
You need to make sure that \" is a String. This can be done by surrounding it with double quotes like this:
"\""
You need to concatenate Strings when printing them by using a
+
Change the last line of code in your question to:
System.out.println("\"" + upperCasePhrase + "\"");
C# appending string from variable inside double quotes
A string.Format
method placeholder is enough to concatenate instance
without cutting through quote signs ({0}
is the placeholder):
var table = string.Format(@"<table id=""table_id{0}"" class=""display"">", instance);
Or you can use escape sequence \"
for escaping quotes without string literal:
var table = "<table id=\"table_id" + instance + "\" class=\"display\">"
Result:
<table id="table_id1234" class="display">
Demo: .NET Fiddle
Put a variable inside double quoted string, but as function parameter in a nested for loop
just use quotes...
soup.select_one(f'a:contains("{m}")')
Related Topics
How to Determine If .Net Core Is Installed
How to Efficiently Remove a Query String by Key from a Url
Ef Migration for Changing Data Type of Columns
Browser Back Button Navigates to Login Page When User Is Still Logged In
Unicode Characters Replace from String Using C#
Web-Api Post Body Object Always Null
How to Generate Database Tables from C# Classes
C# Json.Net How to Ignore a Property in Deserialization But Not in Serialization
Remove the Escape Sequence '\' from String to Convert It to Xmldocument
C# List Join List and Filter from Another List
How to Programmatically Set the System Volume
How to Cast Object to List<Object> and Turn It into an Array
Entity Framework Core With Multiple Foreign Key on Same Column
Check If Task Is Already Running Before Starting New
How to Create ASP.NET Identity Tables in an Already Created Database Using Code First
Automapper - Map Using the Same Source and Destination Object Types
How Avoid Adding Duplicates to Database Managed by Entityframework Caused by Seed Method