All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP截取UTF-8字符串,解决半字符问题_[PHP教程]
利用PHP代码实现网页自动判断转向的实例_php资料_编程技术
C#编程中的,New,关键词的几种用法_[Asp.Net教程]
.NET与常见数据库连接的方式_[Asp.Net教程]
url传递中文的方法_[Asp.Net教程]
asp.net全局异常处理_[Asp.Net教程]
asp.net判断页面加载所用时间_[Asp.Net教程]
支持正则表达式的UrlMapping(ASP.NET2.0)_[Asp.Net教程]
Asp.Net页面输出到EXCEL_[Asp.Net教程]
ASP.NET技巧:下载文件关闭窗体之解决方法_[Asp.Net教程]
Reading number is top 10 pictures
沙漠里的美女
Exquisite decoration is not paying too much4
住院一星期,检测费两万
这才是真正的人体艺术4
Shandong jinan is about to dismantle a one hundred-year history of the building
清纯性感的美眉2
某某人向找小三的人宣战了
美女浴室写真1
Absolutely shocked. National geographic 50 animal photographys10
鸡也看毛片
Download software ranking
WebService在.NET中的实战应用教学视频 → 第2集
XML+Web+Service开发教程
圣殿祭司的ASP.NET.2.0.开发详解-使用C#
The king of fighters 97(Mobile phone games-apk)
Tram sex maniac 2 (H) rar bag7
WebService在.NET中的实战应用教学视频 → 第3集
JSP+Ajax Web development typical examples
Boxer vs Yellow4
Tram sex maniac 2 (H) rar bag9
Boxer Classic video2
qq published in(发表于) 2014/7/11 9:18:21 Edit(编辑)
C#中try-catch

C#中try-catch

C#中try-catch-finally语句的使用方法

C#中try-catch-finally语句的使用方法

异常发生时,执行将终止,同时将控制权交给最近的异常处理语句,这就意味着不能按正常的设计思想执行。而有些资源清理程序(如关闭文件)必须总是执行,为了实现该功能,可以使用finally块。即使有异常情况发生,finally块也可以清除try块中分配的任何资源,以及运行必须执行的代码。控制权将总是传递给finally块,与try块的退出方式无关。

示例

try-catch-finally语句的使用

本示例中有一个导致异常的无效转换语句,当运行程序时,用户会收到一条运行出错的信息,但finally子句仍继续执行并显示输出。程序代码如下:

using System;

public class MainClass

{

static void Main()

{

int i = 123;

string s = "Some string";

// http://www.isstudy.com

object o = s;

try

{

i = (int)o;

}

catch { }

finally

{

Console.Write("i = {0}", i);

}

Console.Read();

}

}



添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.