我有這樣的代碼:與string.replace不是爲我工作
string encodedKeywordsQueryValue = HttpUtility.UrlEncode(HttpContext.Current.Request.QueryString["keywords"]);
query = query.Replace(HttpContext.Current.Request.QueryString["keywords"], encodedKeywordsQueryValue);
其中
HttpContext.Current.Request.QueryString["keywords"] = "abc& abc"
和
encodedKeywordsQueryValue=abc%26+abc
我的老字符串值是沒有得到更換新的。
任何人都可以建議我這樣做嗎?我嘗試過刪除和插入字符串方法的組合,但沒有得到想要的結果。
請幫助我。
查詢變量的值是什麼? –
此方法自.NET 2.0起存在。它已被數噸開發人員使用多年。我不認爲你會得到這種基本操作的意外行爲。 –