當try{}內容不拋錯時,使用try{}和正常執行並無明顯差別
以數組中取值為測試
int xi = test[1];
循環100000000次測試結果如下
當try{}內容拋錯之時,與添加數組長度判斷比較,test為長度為6位的List
以數組中取值為測試
try { int xi = test[7]; } catch (Exception e) { } int xi = test[test.Count - 1];
正常循環100000000次,catch越界錯誤循環1000次對比測試,