-1

我試圖DirectCast對JSON,使用下面的代碼 -如何在Visual Basic 2013中的DirectCast中使用字符串?

​​

的問題是,上述方法僅適用,如果我硬編碼的電子郵件ID到URL。例如DirectCast("http://localhost/[email protected]", HttpWebRequest)。當嘗試獲取電子郵件ID作爲變量,我得到下面的錯誤 - 類型

價值「字符串」不能轉換爲 「System.Net.HttpWebRequest」。

請幫我做這個工作。

+2

['DirectCast'(http://msdn.microsoft.com/en-us/library/7k6y2h6x.aspx)是不是從東西一切轉換工具。 –

+1

如果'DirectCast(URL,HttpWebRequest)'不起作用,我非常懷疑'DirectCast(「http://localhost/[email protected]」,HttpWebRequest)「正在工作。你可能想仔細檢查一下。 –

+0

@ roryap感謝提醒我再次檢查。我忘了在DirectCast(WebRequest.Create(URL),HttpWebRequest)中添加'WebRequest.Create(URL)'。謝謝。 –

回答

0
request = WebRequest.Create(URL) 
+0

我即將發佈相同的內容,忘記在'DirectCast(WebRequest.Create(URL),HttpWebRequest)'中添加'WebRequest.Create(URL)''。謝謝。 –

+0

請將答案標記爲已接受,謝謝。 – djv

+1

我會的,當然。我正在等待5分鐘的stackoverflow時間限制完成:) –

相關問題