Having "'s inside a string [VC#]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
I have the following line of text that I want to store in a STRING
oApp -o -E \STORE* "GRAB ALL SELECT*" (where STORE* and SELECT* are actually variables.

So this gives me the following (I know it doesn't work but it illustrates my point):
string sApp = "oApp -o -E \\" + STORE* + ""GRAB ALL " + SELECT* + "";
Of course that doesn't work at all, it generates a huge list of errors because I am using "s in my string (which is killing everything).
So my question, how do I change sApp (string) so that it works? I need to have "s in my string AND I need to be able to add variables (as I did in the example).

Any help/hints would be greatly appreciated, Thanks,
 
I'm not entirely sure what the line you wanted to create was, but heres how you do it

C#:
string sName = "Shaitan00";
string sString = @"The man said ""Hello " + sName + @"""" + " this is a quote.";

If you want to represent a double quote in a string literal, the escape sequence is two double quotes. Also using @ tells c# to use the literal values for example you could make a path reference as the following without the escape characters for each \.

C#:
string sPath = @"c:\documents and settings\bob\my documents";
 
Back
Top