如何将包含双引号的数据放入字符串变量中? [英] How to put data containing double-quotes in string variable?

查看:28
本文介绍了如何将包含双引号的数据放入字符串变量中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能的重复:
替换 vb.net 中的 "

如何将包含双引号的数据放入字符串变量中?2003 年 8 月 1 日上午 02:30 |友情链接

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"" "

这会给 MyVar 变量一个 some text "hello" 的值.

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

这篇关于如何将包含双引号的数据放入字符串变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆