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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

inserting a Double quote into a string

Status
Not open for further replies.

YvonneTsang

Programmer
Sep 28, 2001
37
CA
I am having problems getting a double quote(") into a string. I thought the structure was string test = "hi ""Tiger"" Woods" to get hi Tiger Woods into my string. Am I mistaken? What is the proper syntax for C#
 
You need to prefix your string with the @ character.
i.e.
string str = @""string in double quote marks here""";

I can't recall the exact number of " characters you need - whether it's 2 or 3 either side of the string - you may need to experiement with this.

Hope that this helps.
Steve
 
I think you can also use the backslash character to escape it, like you'd do in C.

MyString += "\"Tiger Woods\"";

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top