try..catch..finally
来源:互联网 发布:守望先锋辅助软件 编辑:程序博客网 时间:2024/05/07 01:11
try { ProcessString(s); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } finally { } ============================================================ C# |
class TryFinallyTest{ static void ProcessString(string s) { if (s == null) { throw new ArgumentNullException(); } } static void Main() { string s = null; // For demonstration purposes. try { ProcessString(s); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); } }} /* Output: System.ArgumentNullException: Value cannot be null. at TryFinallyTest.Main() Exception caught. * */ |
C# |
class ThrowTest3{ static void ProcessString(string s) { if (s == null) { throw new ArgumentNullException(); } } static void Main() { try { string s = null; ProcessString(s); } // Most specific: catch (ArgumentNullException e) { Console.WriteLine("{0} First exception caught.", e); } // Least specific: catch (Exception e) { Console.WriteLine("{0} Second exception caught.", e); } }}/* Output:System.ArgumentNullException: Value cannot be null. at TryFinallyTest.Main() First exception caught.*/ |
- try..catch..finally
- try-catch-finally
- Try-catch-finally机制
- 关于try-catch-finally
- C# try catch finally
- try...catch...finally
- try catch finally用法
- Try ---Catch----Finally
- try...catch... finally
- try....catch...finally 妙用
- try{} catch(){}finally{}执行
- Try Catch Finally
- try-catch-finally
- C# try, catch ,finally
- try catch finally
- try catch finally
- try-catch-finally
- try...catch...finally
- 查找字符串出现的位置
- n72刷机
- WebService 访问代理及安全性验证设置
- 创新与转型是电信企业的决胜动力
- C#調用存儲過程(帶返回值)和SQL Server DTS的方法
- try..catch..finally
- 经典100句
- 网页背景颜色渐变效果
- 在exp中使用QUERY选项的范例
- win2003服务器允许下载.exe文件的方法
- 美研究人员建立断裂信使RNA库
- 成长
- hibernate数据库分页
- 使用单变量求解进行函数的逆运算