How do you escape double quotes in concatenated strings?

Hi,

How can I get the IDE to ignore double quotes in concatenation exercises (see below):

Code Snippet

Dim myString As String = "This is a "double quote" situation" & myOtherString & " and I need a resolution."
Dim myOtherString As String = "gentlemen"



Any ideas on how you escape those "double quote" double quotes?

Ger

[566 byte] By [GerardL] at [2008-1-7]
# 1

Well you can just use two double quotes in a row:

Dim myString as String = "This is a ""double quote"" situation"

But when you are doing several concats, it is better to use the String.Format method:

Dim myString As String = String.Format("This is a {0}double quote{0} situation {1} and I need a resolution", ControlChars.Quote, myOtherString)

Hope that helps!

rkimble at 2007-10-2 > top of Msdn Tech,Visual Basic,Visual Basic Language...
# 2
Reed,
That is perfect. I particularly like the String.Format method.
Thanks
Ger
GerardL at 2007-10-2 > top of Msdn Tech,Visual Basic,Visual Basic Language...