我有以下代码来执行特定错误代码的某些任务
Using resp As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
Select Case (resp.StatusCode)
Case CType((resp.StatusCode >= HttpStatusCode.Accepted And resp.StatusCode <= HttpStatusCode.Ambiguous), HttpStatusCode)
'do something
Case CType((resp.StatusCode >= HttpStatusCode.BadRequest And resp.StatusCode < HttpStatusCode.InternalServerError), HttpStatusCode)
'log something
Case CType((resp.StatusCode > HttpStatusCode.InternalServerError), HttpStatusCode)
'show something
End Select
End Using
但是没有一个case语句被调用。
答案 0 :(得分:0)
那么你的CType
只是愚蠢的。
和其他代码一样。拿起一本书,上课,仔细阅读MSDN。
Using response As HttpWebResponse = request.GetResponse
Select Case response.StatusCode
Case Is <= HttpStatusCode.Accepted, Is <= HttpStatusCode.Ambiguous
...
End Select
End Using