try-catch-finally(C# 参考)
来源:互联网 发布:排序算法应用 编辑:程序博客网 时间:2024/06/07 17:20
catch 和 finally 一起使用的常见方式是:在 try 块中获取并使用资源,在catch 块中处理异常情况,并在 finally 块中释放资源。
// try_catch_finally.csusing System;public class EHClass{ static void Main() { try { Console.WriteLine("Executing the try statement."); throw new NullReferenceException(); } catch (NullReferenceException e) { Console.WriteLine("{0} Caught exception #1.", e); } catch { Console.WriteLine("Caught exception #2."); } finally { Console.WriteLine("Executing finally block."); } }}
示例输出
Executing the try statement.System.NullReferenceException: Object reference not set to an instance of an object. at EHClass.Main() Caught exception #1.Executing finally block.
- try-catch-finally(C# 参考)
- C# try catch finally
- C# try, catch ,finally
- C# --try catch finally
- C# try catch finally
- C# try catch finally
- C# try、catch、finally
- try-catch(C# 参考)
- 异常(try-catch-finally)
- C# 捕获异常try...catch...finally
- C#中的try catch 和finally
- C#中try catch finally 用法
- C#中的try catch finally用法分析
- C#中try catch finally 用法
- C#中的try catch 和finally
- C#中的异常捕获(try catch finally)
- C#中try catch finally 用法
- C#中try catch finally 用法
- 监听edittext中文字个数变化··
- 关于使用ssh框架时,pojo、dao、service三层的关系 .
- 给定一个十进制数,转换为对应的二进制数
- c# Delegate 例子
- HibernateDaoSupport详解
- try-catch-finally(C# 参考)
- JAVA关键字transient
- 自动ssh登录的几种方法
- [PHP]如果客户端禁用cookie,session还能用吗?(终于找到了答案)
- 生成随即验证码图片
- 哥终于知道了苹果为什么发布的是iPhone 4S而非iPhone 5
- PHP5.3.x安装Zend Optimizer(Zend Guard Loader)[Linux][Windows]
- Java的反射机制, ClassLoader及OSGI
- yahoo论文:Benchmarking Cloud Serving Systems with YCSB