【发布时间】:2011-04-15 02:07:11
【问题描述】:
如何在 vb.net 中替换字符串中的“&”。我试过了:
str2 As String = Replace(str, "&"c, "&")
str2 As String = Replace(str, "&", "&")
str2 As String = Replace(str, chr(38), "&")
由于某种原因,这里的代码不起作用。我在 URL 中使用参数并使用请求来存储参数。它肯定是正确存储的,因为当我调试时,我看到 strOne 正在获取正确的值。
Dim strOne As String = Request("One")
在这里调试中观看 strOne = "ABC D&E"
If Not strOne Is Nothing Then
strOne = strOne.Replace("&", "&")
Else
strOne = String.Empty
End If
然后它去行替换,它没有。为什么??? 好吧,我想通了……
“&”与“&”不一样,所以我从手表上复制并粘贴它并修复它。他们怎么不一样?不同的编码?
谢谢!
【问题讨论】: