我做:C#:增加了兩個字符串
html = new WebClient().DownloadString(
"http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=" + biocompany);
,我得到的錯誤:
Error 1 Operator '&' cannot be applied to operands of type 'string' and 'string'
但我不即使使用&!
請幫忙!
我做:C#:增加了兩個字符串
html = new WebClient().DownloadString(
"http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=" + biocompany);
,我得到的錯誤:
Error 1 Operator '&' cannot be applied to operands of type 'string' and 'string'
但我不即使使用&!
請幫忙!
您發佈的代碼已成功執行。你的問題在別處。
您收到的編譯器錯誤將指示確切地說哪一行失敗,而不是您發佈的行。看看那個開始。
確保您的報價正確無誤。下面的代碼行,例如,會導致完全錯誤您報告:第一個引號(「)之前
html = new WebClient().DownloadString(
"http://www.google.com/search?sourceid=chrome"&"ie=UTF-8&q=" + biocompany);
嘗試@是這樣的:
html = new WebClient().DownloadString(@"http://www.google.com/search?sourceid=chrome&ie=UTF-8&q=" + biocompany);
發佈的字符串中沒有轉義字符這確實有害,但是... – 2010-04-13 05:19:37
反正它是一個很好的代碼實踐。 QA的旁註:) – Amsakanna 2010-04-13 05:57:14
什麼是'biocompany'而且是你*絕對*確定這是錯誤行?如果你註釋掉該行它工作正常嗎?請注意'WebClient'是'IDisposable',所以(無關)應該有一個'使用'在那裏。 – 2010-04-13 05:12:14
Post more代碼,你發佈的代碼片段沒有任何錯誤 – 2010-04-13 05:13:15