【发布时间】:2011-08-10 09:46:21
【问题描述】:
我目前正在尝试在某些代码上添加异常处理程序。该代码只是创建了一个实例。
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(firstline);
我试过了:
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(firstline);
}
catch(Exception ex)
{
// code here
}
我收到以下编译错误:
错误 1 当前上下文中不存在名称“请求”。
通过将 try on 添加到语句中。我错过了什么吗?
【问题讨论】:
-
提示:我怀疑 OP 试图访问 catch 块中的
request。