久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

試著抓住最后的問題

try catch finally question(試著抓住最后的問題)
本文介紹了試著抓住最后的問題的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

在 Try Catch finally 塊中,finally 塊是否始終執(zhí)行,或者僅在 catch 塊不返回錯誤時(shí)執(zhí)行?

In a Try Catch Finally block, does the finally block always execute no matter what, or only if the catch block does not return an error?

我的印象是 finally 塊只有在 catch 塊通過且沒有錯誤的情況下才會執(zhí)行.如果catch塊因?yàn)殄e誤而被執(zhí)行,是不是應(yīng)該一起停止執(zhí)行并返回錯誤信息(如果有)?

I was under the impression that the finally block only executes if the catch block passes without errors. If the catch block is executed because of an error, shouldn't it stop execution all together and return the error message if any?

推薦答案

不僅 finally 塊會在 catch 塊之后執(zhí)行,try 甚至不需要捕獲任何異常來執(zhí)行 finally.以下是完全合法的代碼:

Not only will a finally block execute following a catch block, try does not even require that any exception be caught for the finally to execute. The following is perfectly legal code:

try 
{
//do stuff
}
finally 
{
   //clean up
}

實(shí)際上,當(dāng) catch 塊包含以下內(nèi)容時(shí),我繼承了一些代碼中的 catch 塊:

I actually took out the catch blocks in some code I inherited when the catch block consisted of:

catch(Exception ex)
{
   throw ex;
}

在這種情況下,所需要做的只是清理,所以我只留下了一個(gè) try{} 和 finally{} 塊,讓異常冒泡并保持其堆棧跟蹤完好無損.

In that case, all that was required was to clean up, so I left it with just a try{} and finally{} block and let exceptions bubble up with their stack trace intact.

這篇關(guān)于試著抓住最后的問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Is there a C# library that will perform the Excel NORMINV function?(是否有執(zhí)行 Excel NORMINV 函數(shù)的 C# 庫?)
Select x random elements from a weighted list in C# (without replacement)(從 C# 中的加權(quán)列表中選擇 x 個(gè)隨機(jī)元素(無需替換))
Create a summary description of a schedule given a list of shifts(給定輪班列表,創(chuàng)建時(shí)間表的摘要描述)
C# Normal Random Number(C# 普通隨機(jī)數(shù))
Standard deviation of generic list?(通用列表的標(biāo)準(zhǔn)偏差?)
AsyncCTP: Creating a class that is IAwaitable(AsyncCTP:創(chuàng)建一個(gè) IAwaitable 的類)
主站蜘蛛池模板: 欧美日韩18 | 日本大香伊一区二区三区 | 亚洲色图综合 | 国产精品视频www | 成人在线h | 久久亚洲一区二区三区四区 | 欧美三级三级三级爽爽爽 | 欧产日产国产精品国产 | 56pao在线 | 蜜桃毛片 | 精品国产一区二区国模嫣然 | 中文精品一区二区 | 国产精品s色 | 国产精品免费一区二区 | 日本a级大片 | 日韩精品免费视频 | 欧美a区 | 欧美精品一区在线发布 | 人人性人人性碰国产 | 午夜激情视频在线 | 国产在线1区 | 日日操夜夜摸 | 国产69久久精品成人看动漫 | 亚洲国产成人精品久久久国产成人一区 | 自拍视频国产 | 一区二区免费视频 | 国产精品成人在线 | 国产精品成人av | 成人福利在线观看 | 国产亚洲欧美另类一区二区三区 | 国产精品爱久久久久久久 | 久久视频免费观看 | 精品日本久久久久久久久久 | www成人免费 | 精品久久久久久久人人人人传媒 | 精品综合视频 | 国产欧美日韩综合精品一区二区 | 国产99久久 | 8x国产精品视频一区二区 | 超级乱淫av片免费播放 | www.9191 |