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

試著抓住最后的問題

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

問題描述

在 Try Catch finally 塊中,finally 塊是否始終執(zhí)行,或者僅在 catch 塊不返回錯(cuò)誤時(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 塊通過且沒有錯(cuò)誤的情況下才會執(zhí)行.如果catch塊因?yàn)殄e(cuò)誤而被執(zhí)行,是不是應(yīng)該一起停止執(zhí)行并返回錯(cuò)誤信息(如果有)?

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 的類)
主站蜘蛛池模板: 久在线| 亚洲精品久久久久久一区二区 | 精品免费视频 | 天天色天天射天天干 | av看片网站 | 久久天天躁狠狠躁夜夜躁2014 | 超碰日本 | 日韩视频精品在线 | 欧美在线一区二区三区 | 综合久久av | 国产一区二区三区久久久久久久久 | 久久精品久久精品久久精品 | 黄色在线免费观看视频网站 | 激情六月丁香 | 国产日韩视频 | 日本久久久久久久久 | 日韩在线看片 | 国产精品久久久久久久久久久久冷 | 日本一区二区视频 | 国产精品大全 | 新超碰97 | 欧美日韩成人在线 | 国产一级在线观看 | 国产精品一区二区在线 | 亚洲国产精品久久久 | 中文字幕乱码一区二区三区 | 精品国产伦一区二区三区观看体验 | 嫩草最新网址 | 亚洲成人毛片 | 久久精品网 | 精品欧美一区免费观看α√ | 久久人人网| 天天影视网天天综合色在线播放 | 日韩一区二区福利视频 | 久久亚洲一区 | 波多野吉衣久久 | 国产成人小视频 | 国产传媒在线观看 | 日韩1区| a在线视频| 欧美黄色一区 |