开发者

How to put data containing double-quotes in string variable? [duplicate]

This question already has answers here: Closed 10 years ago.

Pos开发者_如何学Csible Duplicate:

replace " in vb.net

How to put data containing double-quotes in string variable? Aug 01, 2003 02:30 AM | LINK

I need to store a string that contains words in double quotes. The complete string data is presented to the variable in double quotes, but the next double quotes within the data ends the string and the remaining text gives a syntax error. How can I place literal double-quotes in a string variable? For example:

Dim MyVar as string = "stm_bm(["menu53d0",400,"","blank2.gif",0,"","",0,0,250,0,1000,1,0,0,""],this);"


You can escape (this is how this principle is called) the double quotes by prefixing them with another double quote. You can put them in a string as follows:

Dim MyVar as string = "some text ""hello"" hello"

This will give the MyVar variable a value of some text "hello" hello.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜