如果在使用语句中发生异常,对象是否仍会被处理?
我之所以问这个问题,是因为我正在考虑是在整个代码块周围放置try-catch还是在内部using语句中放置。请注意,某些异常在catch块中被设计为重新抛出。
using (SPSite spSite = new SPSite(url))
{
// Get the Web
using (SPWeb spWeb = spSite.OpenWeb())
{
// Exception occurs here
}
}