VB.NET2010问题
Imports System.IO
Imports System.Net
Imports System.Web
Imports System.Collections.Generic
Public Class GoogleClient
#Region "Using WebRequest"
Public Function define(ByVal word As String) As String()
Dim req As HttpWebRequest = Nothing
Dim resp As HttpWebResponse
Dim query As String
Dim result As New List(Of String)
query = "http://www.google.com/search?q=define%3A" & HttpUtility.UrlEncode(word)
Try
req = DirectCast(WebRequest.Create(query), HttpWebRequest)
With req
.Method = "GET"
resp = req.GetResponse
If resp.StatusCode = HttpStatusCode.OK Then
parseResponse(resp.GetResponseStream, result)
Else
MessageBox.Show("Error Calling definition service")
End If
End With
Catch ex As Exception
End Try
Return result.ToArray()
End Function
这是我写的程序的一部分,为什么会提示HttpUtility未声明呢??资料上也说有这个类,是不是还要定义HttpUtility呢?
[解决办法]
Imports System.Web 虽然指定了名字,但是你并没有引用system.web是.netframe里面的组件
[解决办法]
没有添加引用
注意 不光要imports
还必须在工程里面添加引用