Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

placing quotes within quotes 1

Status
Not open for further replies.

GoTerps88

Programmer
Apr 30, 2007
174
US
I'm looking for a way to place quotes within quotes and after constantly looking at it, I can't find the answer. So I thought the best approach would be to ask someone smarter than me.

int intYear = "2007"

string str = "He yelled " + intYear.ToString() + " at the top of his voice.";

This doesn't work for me because it prints out:
He yelled 2007 at the top of his voice.

I need the string to look like this:
He yelled "2007" at the top of his voice.
 
Code:
string str = "He yelled [b]\"[/b]" + intYear.ToString() + "[b]\"[/b]  at the top of his voice.";

Hope this helps,

Alex



[small]----signature below----[/small]
I'm pushing an elephant up the stairs

My Crummy Web Page
 
better practice is to use the escape sequence posted by Alex - using char(34) makes it hard to see what character you're looking at unless you have an ascii chart on hand - and you can't do it inline

"\"this is a quote\""

vs

chr(34) + "this is a quote" + chr(34)

 
Is String.Format similar to printf from C? I haven't done C in a while, but it looks familiar
 
And yet another way to do this:

Code:
string str = @"He yelled """ + intYear.ToString() + @"""  at the top of his voice.";
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top