简体   繁体   English

如何在vb.net中执行字符串连接?

[英]how to perform string concatenation in vb.net?

This is string value <a href="javascript:changePage('5')">Overview</a> .Now i want to store it in a string in vb.net. 这是字符串值<a href="javascript:changePage('5')">Overview</a> 。现在,我想将其存储在vb.net中的字符串中。

How do i store it. 我如何存储它。

Dim link As String="<a href="javascript:changePage('5')">Overview</a>"

Please guide me to get out of this issue? 请指导我摆脱这个问题?

You need to escape the inner " by doubling them: 您需要通过将它们加倍来逃脱内部"

Dim link As String="<a href=""javascript:changePage('5')"">Overview</a>"

The C# version can be one of: C#版本可以是以下之一:

var link = @"<a href=""javascript:changePage('5')"">Overview</a>"

var link = "<a href=\"javascript:changePage('5')\">Overview</a>"

Just use single quotes within the literal denoted by double quotes. 只需在双引号表示的文字中使用单引号。 Doing this with markup that will be output to the browser will result in invalid markup for single quotes within quotes - in that case you can escape the double quotes with another 'set' of double quotes. 与标记这样做,这将是输出到浏览器将导致引号内无效的标记单引号-在这种情况下,你可以逃脱与另一双引号的“设置”双引号。

Dim link As String = "<a href=""javascript:changePage('5')"">Overview</a>"

I have been out of VB.NET for a long time, in C-Sharp it can be done like: 我已经离开VB.NET很长时间了,在C-Sharp中可以这样完成:

String link = "<a href=\"javascript:changePage('5')\">Overview</a>";

I hope it will give you an idea, you will have to escape the inner double quotes. 我希望它能给您一个主意,您必须转义内部的双引号。

用途如下:

Dim link As String = "<a href=\"javascript:changePage('5')\">Overview</a>"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM