C#, try/catch when 的寫法。
我竟然錯過了 C# 6.0 這麼漂亮的寫法 (之前只看到用在 switch case)
※ 那段 WinDbg 出來的內容,可以看到兩種寫法雖然執行結果一樣,但要看 exception 相關資訊時來進行偵錯,就差很多了!
而且至少寫法漂亮一點了,畢竟 exception 在 error handling 時,的確很常會依據條件來進行決定 handle 或不 handle, 可以省掉不必要的 throw。
補上 MSDN when 的說明:https://docs.microsoft.com/…/language-referen…/keywords/when
「c# try catch throw」的推薦目錄:
c# try catch throw 在 Lesson 34 - Exception Handling (try, catch, throw and finally) 的美食出口停車場
![影片讀取中](/images/youtube.png)
C# Beginner to advanced - Lesson 34 - Exception Handling (try, catch, throw and finally). Watch later ... ... <看更多>
c# try catch throw 在 throw ... - 程式語言教學誌FB, YouTube: PYDOING: C# 快速導覽 的美食出口停車場
class Demo { static void Main() { string s = null; try { if (s == null) { throw new System.Exception(); } } catch { System.Console. ... <看更多>
c# try catch throw 在 91 敏捷開發之路- C#, try/catch when 的寫法。 我竟然錯過了C# ... 的美食出口停車場
我竟然錯過了C# 6.0 這麼漂亮的寫法(之前只看到用在switch case) ※ 那段WinDbg 出來的內容, ... try { throw new ArgumentNullException(nameof(i)); } catch (. ... <看更多>