最后......

扫码查看
本文介绍了最后......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我只是在思考最后一个异常实际上是什么?b $ b。好吧,我意识到无论是否抛出异常,它总是会被调用,但是不是和下一个 代码行相同吗?这两段代码之间的区别是什么: 尝试 { WriteFile(); } catch { //亲爱的 Trace.Write("数据丢失); } 终于 { //清理代码 关闭文件(); } 和 尝试 { WriteFile(); } catch { //哦亲爱的 Trace.Write(数据丢失); } //清理代码 关闭文件(); 干杯 andyt 解决方案I was just pondering about what the Finally in an exception actuallydoes. Well, I realise that it always gets called regardless of whetherthe exception is thrown or not, but isn''t that the same as the nextlines of code? What''s the difference between these two bits of code:try{WriteFile();}catch{// Oh dearTrace.Write ("Data lost");}finally{// cleanup codeCloseFile();}andtry{WriteFile();}catch{// Oh dearTrace.Write ("Data lost");}// Cleanup codeCloseFile();Cheersandyt 解决方案 这篇关于最后......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
05-27 23:42
查看更多