看板 Soft_Job 關於我們 聯絡資訊
這是一個method... protected override void CompressAttachment(mimeParser oMIME, string sZipFileName, string sPwd) { .... return; ClearupAndThrow: if (oZip != null) { oZip.Close(); } throw oAppEx; } 請問在return; 下方的code, ClearupAndThrow: 這樣寫是有效果的嗎!? 感謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 175.184.246.138 ※ 文章網址: https://www.ptt.cc/bbs/Soft_Job/M.1429252120.A.657.html
GoalBased: 你的IDE沒跟你說那邊不會被執行到嗎 04/17 14:33
zhuzii: 呃... 雖然不會 c# 無法回. 其實有 c-sharp 板 04/17 14:34
YahooTaiwan: 有用阿,goto 會用到 04/17 14:40
YahooTaiwan: 你寫 goto CleanupAndThrow; 試試 04/17 14:41
robler: 只看這一段的話 return;以後都不會被執行到 04/17 14:56
robler: 史上最強IDE應該會把後面的程式碼都變灰色的 04/17 14:56
doomdied: goto會到吧 04/17 15:11
liddle: 推 robler, V.S.這個時候已經灰掉這段code了 04/17 15:15
kyork: 講到goto就可以來場大論戰了 04/17 15:18
sing10407: 沒寫過goto 不過大學老師一提到就叫我們絕對不要用.... 04/17 15:26
neotek: Xcode寫Obj-C如果這樣寫~會跳warning跟你說後面不會執行到 04/17 15:27
discoby: ??應該所有的IDE都會提示那段是dead code吧 04/17 15:43
littleshan: 這是個典型的拿C語言思維寫C# 04/17 15:48
littleshan: 他想做exception safe,但這樣寫一點也不safe 04/17 15:49
littleshan: C++ 請用 RAII,C# 請用 IDisposable 搭配 using 04/17 15:49
saladim: 一點都不像exception safe.... close也可能throw阿 04/17 15:53
GoalBased: 看變數命名就知道他本來不是寫C#的阿 04/17 16:03
psliurt: 變數命名方法是匈牙利命名法嗎?難道是MFC!!!! 04/17 17:45
snaketsai: C可能要看最佳化的結果,有點忘記規範有沒有說 04/17 22:37
wuliou: 這根本不是C#... 04/17 23:54
okalala1234: 用finally吧唉 04/18 01:12
Agliny: return;後面不會有動作吧…因為我都這樣deBug(/艸) 04/18 13:27