tags:

views:

121

answers:

4

Hi,

I want to add double quote in c# string.

string searchString = "123";
string inputString = "No matches found for "+ "\""+searchString + "\"";

OutPut: No matches found for "123"

THanks,

+3  A: 

I thing that what you need is string format. For example: string.format("No matches found for \"{0}\"", searchString);

Ikaso
A: 

try this

string inputString = "No matches found for "+" "+searchString ;

Vyas
That will do nearly nothing (it will just add an empty string between `for` and `searchString`).
Fredrik Mörk
A: 
string inputString = String.Format(@"No matches found for \"{0}\"", searchString);
Michael Pakhantsov
This won't even compile! Proper escape for double quote in a verbatim string is "" (twice the double quote), so it would become String.Format(@"No matches found for ""{0}""", searchString);
maciejkow
To the above comment: Why not just say that the at-sign should be removed?
jgauffin
@jgauffin, :) down-voting is power! :)
Michael Pakhantsov
+1  A: 

What you have should produce what your expecting:

No matches found for "123"

You could also try:

string searchString = "123";
string inputString = String.Format(@"No matches found for ""{0}""!", searchString);
SwDevMan81