<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>
<title><![CDATA[金石博客 LVZZ BLOG]]></title>
<link>http://lvzz.zwms.net/</link>
<description><![CDATA[精诚所至-金石为开-吕正正]]></description>
<language>zh-cn</language>
<copyright><![CDATA[Copyright 2005 PBlog3 v2.8]]></copyright>
<webMaster><![CDATA[lvzz.net@gmail.com(天狼)]]></webMaster>
<generator>PBlog2 v2.4</generator> 
<image>
	<title>金石博客 LVZZ BLOG</title>
	<url>http://lvzz.zwms.net/images/logos.gif</url>
	<link>http://lvzz.zwms.net/</link>
	<description>金石博客 LVZZ BLOG</description>
</image>

			<item>
			<link>http://lvzz.zwms.net/article/程序研发/145.htm</link>
			<title><![CDATA[WebService服务提供商]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[程序人生]]></category>
			<pubDate>Sat,06 Feb 2010 01:33:12 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=145</guid>
		<description><![CDATA[<p>这是一家WebService服务提供商，提供很多项WebService服务。</p>
<p>以前上过，收藏过，后来不是收藏到哪里去了，现在重新收藏到博客里面吧。</p>
<p>http://www.webxml.com.cn/zh_cn/index.aspx</p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/技术拾荒/144.htm</link>
			<title><![CDATA[XP系统下格式化U盘为NTFS格式]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[技术拾荒]]></category>
			<pubDate>Tue,08 Sep 2009 23:05:38 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=144</guid>
		<description><![CDATA[<p>一直以为XP系统不能格式化U盘为NTFS格式，这几天一琢磨，原来还是可以的。方法如下：</p>
<p><span style="color: #ff6600"><strong>插上U盘，右键，属性，硬件，选择磁盘驱动器的名称双击，点&ldquo;策略&rdquo;标签，选择&ldquo;提高性能而优化&rdquo;，确定。</strong></span></p>
<p>完毕。现在可以开始格式化U盘为NTFS格式了。</p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/技术拾荒/143.htm</link>
			<title><![CDATA[在线制作ICON图标]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[技术拾荒]]></category>
			<pubDate>Mon,17 Aug 2009 11:34:19 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=143</guid>
		<description><![CDATA[<div class="postTitle">今天无意中访问到一个能在线制作收藏夹ICON图标的网站，俺不敢私藏，特别把用法写下来，供各位使用。</div>
<p>该网站网址是：<a target="_blank" href="http://www.chami.com/html-kit/services/favicon/" class="contentlink">http://www.chami.com/html-kit/services/favicon/</a>（EN）</p>
<p>是个非常有特色的网站喔。打开后，点击浏览按钮就可以选择你想要制作成ICON的图片了。支持gif、jpg和bmp。不过我推荐大家使用gif。因为gif可以用透明嘛。<br />
&nbsp;</p>
<p><img src="http://tnt2.cn/blog/attachments/month_0610/02006103224255.gif" alt="" /></p>
<p>点击Generate Favlcon.ico开始制作。中间根据你上传的图片的大小，会有相应的等待时间。</p>
<p><img src="http://tnt2.cn/blog/attachments/month_0610/o2006103224453.gif" alt="" /></p>
<p>制作完毕后，点击页面上那个蓝色的Download FavIcon按钮，就可以下载压缩包了。压缩包里的favicon.ico就是根据你上传的图片，制作而成的ICON图标。extra目录里还有一个滚动显示图标的gif文件和一个静态显示图标的png图标。</p>
<p>是不是一个非常令人惊喜的Web功能呢？快去试试吧。说不准能发现一些更好玩的东西呢？</p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/技术拾荒/142.htm</link>
			<title><![CDATA[iphone3.0正式版降级到2.2.1方法]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[技术拾荒]]></category>
			<pubDate>Tue,28 Jul 2009 14:55:25 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=142</guid>
		<description><![CDATA[<p>iphone 2G和3G 手机系统升级成3.0正式版时,如果需要降级到2.2.1,那么可以按以下方法操作(每一步都很重要，切忌！！):<br />
<br />
1. 先把iphone状态变成，紧急呼叫模式（不能是itunes恢复模式，下面有个USB数据线那个）<br />
2. 进入windows程序管理，删除5个关于apple的相关程序，itunes,apple mobile device support,bonjour,apple software update,quick time.<br />
3. 进入桌面上的我的文档，我的音乐，里面有个iTunes的文件夹，删除它！！<br />
4. 重启电脑，安装iTunes8.0.2（网络搜索下，有下载）<br />
5. 启动iTunes，插上iphone（如果提示&ldquo;不能使用iphone，因为它要求itunes8.2或更高版本&hellip;&hellip;&rdquo;不用管它，继续往下操作就可以），将iphone进入DFU模式（黑屏那个）<br />
6. iTunes辨认出iphone，shift+恢复，2.2.1官方固件。（网络搜索下，有下载）<br />
7. 安装.net 2.0，然后越狱（不再介绍越狱方法）<br />
8. shift+恢复，2.2.1自定义固件。</p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/技术拾荒/141.htm</link>
			<title><![CDATA[Windows Server 2003安装iTunes的经验分享]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[技术拾荒]]></category>
			<pubDate>Thu,23 Jul 2009 11:12:10 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=141</guid>
		<description><![CDATA[<p>在windows 2003上, 想要装iTunes 8.X.<br />
<br />
直接报说 Apple Mobile Device Support只支持Windows XP SP2以上版本,没有安装成功,其它组件的都成功安装了.<br />
<br />
Google了一把, 发现解决方案, 现拿上来分享一下.<br />
<br />
1. 准备好iTune 8.X<br />
2. 下载附件中的Orca,安装完毕<br />
3. 用Winrar解压缩iTune的安装文件 (iTunesSetup.exe) 到一个文件目录下.<br />
4. 用Orca打开解压出来的 AppleMobileDeviceSupport.msi.<br />
5. 在左边列表中找到LaunchCondition, 右击, 选择Drop Table... 删掉这项, 直接点击保存.<br />
6. 直接双击修改好的 AppleMobileDeviceSupport.msi 就可以安装成功了.<br />
<br />
写完,留个记录,以备以后查阅</p>
<div class="box postattachlist">
<p><a href="http://www.weiphone.com/thread-358070-1-1.html#zoom"><img height="228" alt="Orca.jpg" width="481" border="0" onclick="zoom(this, 'http://images.weiphone.com/attachments/day_090514/20090514_79b0051e334b60ae2229xK0EH1slss0t.jpg')" src="http://images.weiphone.com/attachments/day_090514/20090514_79b0051e334b60ae2229xK0EH1slss0t.jpg.thumb.jpg" /></a></p>
<p>&nbsp;</p>
<dl class="t_attachlist"></dl>
<p>&nbsp;</p>
<dl class="t_attachlist"><dt><img class="absmiddle" alt="" border="0" src="http://www.weiphone.com/images/attachicons/rar.gif" /> <a target="_blank" href="http://www.weiphone.com/attachment.php?aid=422291&amp;k=e1882e66ff0cda6a5089a96c16cca6f0&amp;t=1248317930">orca.rar</a> <em>(1.55 MB)</em> </dt></dl></div>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/哲理思想/139.htm</link>
			<title><![CDATA[别把猪惹急了！]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[哲理思想]]></category>
			<pubDate>Wed,03 Jun 2009 09:05:52 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=139</guid>
		<description><![CDATA[<div id="blogDetailDiv" style="font-size: 16px;"><span style="font-size: 12px;"><span style="font-family: 宋体;">不是一次看到这篇文章了，每次看到都会有新的版本。这次看到的感觉最全面。摘抄欣赏&hellip;&hellip;</span></span></div>
<div id="blogDetailDiv" style="font-size: 16px;"><span style="font-size: 12px;"><span style="font-family: 宋体;">&nbsp;</span></span></div>
<div id="blogDetailDiv" style="font-size: 16px;"><span style="font-size: 12px;"><span style="font-family: 宋体;">很多年前，虎太霸道了，狼就和虎打架，狼打不过虎，狼看猪多，于是想让猪帮忙。猪问：有什么好处？狼说，打胜了，把虎的地送给你们。于是猪帮狼赶跑了虎，狼讲义气，把土地分给了猪。做砖家的狐狸就对狼说：土地全给了猪，狼你吃个屁去。狼想想对，就把猪的地全收了回来，由于是狼翻脸，猪想想也没有什么办法，但至少狼还是给了猪福利分窝的待遇。过了几年狐狸又给狼出了一个主意，说猪窝不能白送，福利猪窝改成商品猪窝。于是猪要掏钱才能买，由于要建商品猪窝，搞工程的王八，卖地的狼，做砖家的狐狸就有钱挣了，可是猪窝造好了，猪太穷了，口袋里只有五块钱，买不起，狼请做砖家的狐狸想办法，狐狸说：没钱，可以按揭啊，于是开银行的老鼠大量的印钱，等着猪来借。搞工程的王八找来了好多兄弟乌龟、鳖、甲鱼排在售窝处。让猪总觉的猪窝又要涨价了，于是纷纷也来排队，对于猪而言，只要老鼠肯借钱，涨一点就多问老鼠多借一点，买窝的积极性还是很大的，温州的野猪还成立了温州炒窝团。随着老鼠贷出去的钱越来越多，市场上钱多了，猪窝就越贵。猪就是把猪仔的肉卖了也无济于事。一只叫任志强的王八吵的最凶，还在喊，要涨价啦！搞工程的王八们经常吵架，有一只叫王石的王八突然说：买窝再等三年，猪窝价格要出现拐点了，于是没买窝的猪就等拐点，等着猪窝降价，这时做砖家的狐狸发表评论；作为刚性需求，相对于猪肉，猪窝还不算贵！由于猪们的意见太大，狼倒是建了一批经济适用猪窝和廉租猪窝。猪那个欢天喜地呀，可是等经济适用窝建成了，往里搬家的是狐狸、狮子、熊、毒蛇，全是狠角色，竟看不见猪能搬进去。有一天，猪们再也还不起按揭了，开银行的老鼠就急了，老鼠要的是猪还钱，而猪口袋里除了猪窝就只有大粪了。猪窝卖不出去搞工程的王八就不问狼买地，价格也出不高了，所以地方狼的日子也不好过了，就问责狐狸，于是做砖家的狐狸再次跳出来说：猪还不起贷款，不是猪窝太贵，而是流动性出了问题。于是在狐狸的理论下，老鼠又可以拼命的印钱发放贷款，很快四万亿就进入了市场，市场上的钱更多，于是到处在涨价，钱多没地方去，又进入了猪窝市场，猪窝越发的上涨。而猪们现在连饲料也吃不起了，连大便也不敢多大了。猪百思不得其解，为什么连饲料都吃不起了，还不能有个猪窝呢，所有的猪在想其原因的时候，狐狸再跳出来说：高房价有助共赢！小朋友们，你们说，卖地的狼、搞工程的王八、开银行的老鼠和做砖家的狐狸，哪一个更坏呢？ <!--v:3.2--></span></span></div>
<p><span style="font-size: 12px;"><span style="font-family: 宋体;"><br />
</span></span></p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/程序研发/137.htm</link>
			<title><![CDATA[理解.NET中的数据库连接池]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[程序人生]]></category>
			<pubDate>Wed,06 May 2009 09:40:25 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=137</guid>
		<description><![CDATA[<p class="MsoNormal" align="center" style="text-align: center"><strong><span style="font-family: 宋体">理解</span><span lang="EN-US">.NET</span></strong><strong><span style="font-family: 宋体">中的数据库连接池</span><span lang="EN-US"><o:p></o:p></span></strong></p>
<div align="center"><strong><span style="font-weight: normal; font-size: 10.5pt; font-family: 宋体">作者</span><span style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;"> </span></strong><span lang="EN-US" style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;"><a href="http://aspalliance.com/author.aspx?uId=58780">Joydip Kanjilal</a></span></div>
<p class="MsoNormal" align="left" style="text-align: left"><strong><span style="color: red; font-family: 宋体">摘要</span><span lang="EN-US" style="color: red">:<o:p></o:p></span></strong></p>
<p class="MsoNormal" align="left" style="text-align: left"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">连接池能在程度上提高数据库访问性能。本文讨论到底何为连接池，它如何提高数据库访问性能，以及如何在</span><span lang="EN-US">.NET</span><span style="font-family: 宋体">中创建连接池并增加或移除连接。</span></p>
<p class="MsoNormal" align="left" style="text-align: left"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><strong><span style="color: red; font-family: 宋体">导言</span><span lang="EN-US" style="color: red"><o:p></o:p></span></strong></p>
<p class="MsoNormal"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">连 接数据库是应用程序中耗费大量资源且相对较慢的操作，但它们又是至关紧要的。连接池是已打开的及可重用的数据库连接的一个容器。连接池在所有的数据库连接 都关闭时才从内存中释放。使用连接池最基本的好处是提高应用程序的性能及可伸缩性，而其主要缺点是会有一个或多个数据库连接将一直保持打开状态，即使当前 不在使用。</span><span lang="EN-US">ADO.NET</span><span style="font-family: 宋体">的</span><span lang="EN-US">Data Providers</span><span style="font-family: 宋体">将默认情况下将使用连接池，如果你不想使用连接池，必须在连接字符串中指定</span><span lang="EN-US">&rdquo;Polling=false&rdquo;</span><span style="font-family: 宋体">。 连接池中为你提供了空闲的打开的可重用的数据库连接，而不再需要每次在请求数据库数据时新打开一个数据库连接。当数据库连接关闭或释放时，将返回到连接池 中保持空闲状态直到新的连接请求到来。如果我们有效地使用连接池，打开和关闭数据库将不再很耗费资源。本文讨论连接池的相关内容以及如何有效的使用连接池 来提高应用程序的效率及可伸缩性。</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><strong><span style="color: red; font-family: 宋体">连接池如何工作</span><span lang="EN-US" style="color: red"><o:p></o:p></span></strong></p>
<p class="MsoNormal"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">连 接池中包含打开的可重用的数据库连接。在同一时刻同一应用程序域中可以有多个连接池，但连接池不可以跨应用程序域共享。注意：一个连接池是通过一个唯一的 连接字符串来创建。连接池是根据第一次请求数据库连接的连接字符串来创建的，当另外一个不同的连接字符串请求数据库连接时，将创建另一个连接池。因此一个 连接字符中对应一个连接池而不是一个数据库对应一个连接池。如以下代码所示</span></p>
<p class="codelistingheading">代码<span lang="EN-US">1</span></p>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">//&nbsp;</span><span style="font-size: 8.5pt; color: green">新建一个连接池</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">SqlConnection&nbsp;sqlConnection&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">new</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"> SqlConnection();<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">sqlConnection.ConnectionString&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; background: rgb(228,228,228) 0% 50%; color: rgb(102,102,102); font-family: &quot;Courier New&quot;; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial">&quot;Server=localhost;Database=test;User ID=joydip;Password=joydip;Trusted_Connection=False&quot;</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">sqlConnection.Open();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></pre>
<p class="codelistingheading">代码<span lang="EN-US">2</span></p>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">//&nbsp;</span><span style="font-size: 8.5pt; color: green">因为连接字符串不同，新建另一个连接池</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">SqlConnection&nbsp;conn&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">new</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;SqlConnection();<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">sqlConnection.ConnectionString&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; background: rgb(228,228,228) 0% 50%; color: rgb(102,102,102); font-family: &quot;Courier New&quot;; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial">&quot;Server=localhost;Database=test;User ID=test;Password=test;Trusted_Connection=False&quot;</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">sqlConnection.Open();&nbsp;&nbsp;&nbsp;</span></pre>
<p class="codelistingheading">代码<span lang="EN-US">3</span></p>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">//&nbsp;</span><span style="font-size: 8.5pt; color: green">因为连接字符串与代码</span><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">1</span><span style="font-size: 8.5pt; color: green">相同，不再创建连接池</span><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">.</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">SqlConnection&nbsp;conn&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">new</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;SqlConnection();<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">sqlConnection.ConnectionString&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; background: rgb(228,228,228) 0% 50%; color: rgb(102,102,102); font-family: &quot;Courier New&quot;; moz-background-clip: -moz-initial; moz-background-origin: -moz-initial; moz-background-inline-policy: -moz-initial">&quot;Server=localhost;Database=test;User ID=joydip;Password=joydip;Trusted_Connection=False&quot;</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">sqlConnection.Open();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></pre>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 21pt"><span style="font-family: 宋体">当 有新的数据库连接请求到来时，连接池中连接进行了响应而不用创建一个新的数据库连接，也就是说数据库连接可以被重用，而不需要重新新建连接。因此这提高了 应用程序的效率和可伸缩性。当你在应用程序中关闭一个打开的数据库连接时，该连接返回到连接池中等待重新连接直到等待超时。在这个时间内等待同一数据库相 同连接信息的连接请求。如果这个时间内没有连接请求，这个数据库连接将被关闭，并从连接池中移除这个连接实例。</span></p>
<p class="MsoNormal" style="text-indent: 21pt"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">当一个新的连接池创建后，数据库连接被添加到池中，连接池和池中的连接立即可被使用。连接池中将填满连接字个串中指定的最小连接数量的连接。连接池中连接在长时间不活动或超出指定的生存期时将被移除。</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">连接池由连接池管理器维护。当后续的连接请求到来，连接池管理器在连接池中寻找可用的空闲的连接，如果存在就交给应用程序使用。以下描述了当一个新的连接请求到来时连接管理器如何工作</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">如果有未用连接可用，返回该连接</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">如果池中连接都已用完，创建一个新连接添加到池中</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span lang="EN-US"> </span><span style="font-family: 宋体">如果池中连接已达到最大连接数，请求进入等待队列直到有空闲连接可用</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 21pt"><span style="font-family: 宋体">通过连接字符串中传递的参数可以控制连接池。基本的参数包括：</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang="EN-US">Connect Timeout</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span lang="EN-US">Min Pool Size</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span lang="EN-US"> Max Pool Siz</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span lang="EN-US"> Pooling</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal" style="text-indent: 21pt"><span style="font-family: 宋体">为了有效的使用连接池，记住数据库操作完成后马上关闭连接，这样连接才能返回连接池中。</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><strong><span style="font-family: 宋体">提高连接池性能</span><span lang="EN-US"><o:p></o:p></span></strong></p>
<p class="MsoNormal"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">我 们应该在最晚时刻打开连接并在最早时刻释放连接，即在使用完成后立即释放。数据库连接应该在真正请求数据时才打开，而不应在使用之前就请求连接，这会减少 池中可用连接的数量，因此有害于连接池的操作及应用程序性能。数据库连接应使用完成后立即释放，这能促进连接池更好的使用，因为连接可以返回池中被重新使 用。以下代码展示如何在应用程序中有效地打开和关闭连接</span></p>
<p class="MsoNormal"><span lang="EN-US" style="color: red"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="codelistingheading">代码<span lang="EN-US">4</span></p>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">SqlConnection&nbsp;sqlConnection&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">new</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"> SqlConnection(connectionString);<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">try</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">{<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;&nbsp;sqlConnection.Open();<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">//Some&nbsp;Code</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">}<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">finally</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">{<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;&nbsp;sqlConnection.Close();<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">}</span></pre>
<p class="MsoNormal"><span style="font-family: 宋体">代码</span><span lang="EN-US">4</span><span style="font-family: 宋体">可以使用</span><span lang="EN-US">&rdquo;using&rdquo;</span><span style="font-family: 宋体">关键字进一步简化如以下代码所示</span></p>
<p class="codelistingheading">代码<span lang="EN-US">5</span></p>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">using</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">(SqlConnection&nbsp;sqlConnection&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: red; font-family: &quot;Courier New&quot;">=</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: blue; font-family: &quot;Courier New&quot;">new</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"> SqlConnection(connectionString))<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">{<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;&nbsp;sqlConnection.Open();<o:p></o:p></span></pre>
<pre><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">&nbsp;&nbsp;</span><span lang="EN-US" style="font-size: 8.5pt; color: green; font-family: &quot;Courier New&quot;">//Some&nbsp;Code</span><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;"><o:p></o:p></span></pre>
<p class="MsoNormal"><span lang="EN-US" style="font-size: 8.5pt; color: black; font-family: &quot;Courier New&quot;">}</span><span lang="EN-US" style="color: red"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color: red"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 宋体">注：以上代码</span><span lang="EN-US">5</span><span style="font-family: 宋体">中的</span><span lang="EN-US">&rdquo;using&rdquo;</span><span style="font-family: 宋体">关键字将隐含地生成</span><span lang="EN-US">try-finally</span><span style="font-family: 宋体">块</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 宋体">以下列举了更好地使用连接池的几个可参考要点</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">在需要使用时才打开连接，并在完成操作后马上关闭</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">在关闭连接时先关闭相关用户定义的事务</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span lang="EN-US"> </span><span style="font-family: 宋体">确保维持连接池中至少有一个打开的连接</span><span lang="EN-US" style="color: red"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">在使用集成身份验证的情况下避免使用连接池</span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 宋体">连接池可以通过以下途径进行监控</span><span lang="EN-US"> </span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">使用</span><span lang="EN-US">sp_who</span><span style="font-family: 宋体">或</span><span lang="EN-US">sp_who2</span><span style="font-family: 宋体">存储过程</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">使用</span><span lang="EN-US">SQL Server</span><span style="font-family: 宋体">的</span><span lang="EN-US">Profiler<span style="color: red"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-family: Symbol">&middot;</span><span lang="EN-US" style="font-size: 7pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-family: 宋体">使用性能监视器的性能计数器</span><span lang="EN-US" style="color: red"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="color: red"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><strong><span style="color: red; font-family: 宋体">参考文献</span><span lang="EN-US" style="color: red"><o:p></o:p></span></strong></p>
<p class="MsoNormal"><span lang="EN-US"><a href="http://www.15seconds.com/issue/040830.htm">Tuning Up ADO.NET Connection Pooling in ASP.NET Applications</a></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconconnectionpoolingforsqlservernetdataprovider.asp">Connection Pooling for the .NET Framework Data Provider for SQL Server</a></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsqlmag03/html/The_NETConnectionPoolLifeguard.asp">The .NET Connection Pool Lifeguard</a></span></p>
<p class="MsoNormal"><span lang="EN-US"><a href="http://www.ondotnet.com/pub/a/dotnet/2004/02/09/connpool.html?page=last">ADO.NET Connection Pooling Explained</a></span></p>
<p class="MsoNormal"><span lang="EN-US"><!--[if !supportEmptyParas]-->&nbsp;<!--[endif]--><o:p></o:p></span></p>
<p class="MsoNormal"><strong><span style="color: red; font-family: 宋体">结语</span><span lang="EN-US" style="color: red"><o:p></o:p></span></strong></p>
<p class="MsoNormal"><span lang="EN-US"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: 宋体">连 接池是数据库连接对象的容器，只要其中存在活动的或打开的连接它维持活动状态。当使用一个连接字符串来请求数据库连接时，将分配一个新的连接池。通过在应 用程序中使用相同的连接字符串我们可以提高应用程序的性能和可伸缩性。然而如果我们不正确地使用连接池可能给我们的应用程序带来负效果。</span><span lang="EN-US">MSDN</span><span style="font-family: 宋体">中说&ldquo;连接是提高应用程序性能的有力工具，但如果使用不当连接池非但不是有益的而且是害的&rdquo;。本文讨论了连接池的相关内容以及如何有效的使用连接池来提高应用程序的效率及可伸缩性。</span></p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/程序研发/136.htm</link>
			<title><![CDATA[c#中异常捕获catch{}常用的异常类型]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[程序人生]]></category>
			<pubDate>Tue,05 May 2009 11:00:28 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=136</guid>
		<description><![CDATA[<h2>c#中异常捕获catch{}常用的异常类型</h2>
<div class="postBody">
<table cellspacing="0" cellpadding="3" border="1" style="width: 550px; border-collapse: collapse;">
    <tbody>
        <tr>
            <td>
            <p align="center">Exception 类</p>
            <p>&nbsp;</p>
            </td>
            <td>
            <p align="center">描述</p>
            <p>&nbsp;</p>
            </td>
        </tr>
        <tr height="25" width="150">
            <td>SystemException</td>
            <td>其他用户可处理的异常的基本类</td>
        </tr>
        <tr height="25" width="150">
            <td>ArgumentException</td>
            <td>方法的参数是非法的</td>
        </tr>
        <tr height="25" width="150">
            <td>ArgumentNullException</td>
            <td>一个空参数传递给方法，该方法不能接受该参数</td>
        </tr>
        <tr height="25" width="150">
            <td>ArgumentOutOfRangeException</td>
            <td>参数值超出范围</td>
        </tr>
        <tr height="25" width="150">
            <td>ArithmeticException</td>
            <td>出现算术上溢或者下溢</td>
        </tr>
        <tr height="25" width="150">
            <td>ArrayTypeMismatchException</td>
            <td>试图在数组中存储错误类型的对象</td>
        </tr>
        <tr height="25" width="150">
            <td>BadImageFormatException</td>
            <td>图形的格式错误</td>
        </tr>
        <tr height="25" width="150">
            <td>DivideByZeroException</td>
            <td>除零异常</td>
        </tr>
        <tr height="25" width="150">
            <td>DllNotFoundException</td>
            <td>找不到引用的DLL</td>
        </tr>
        <tr height="25" width="150">
            <td>FormatException</td>
            <td>参数格式错误</td>
        </tr>
        <tr height="25" width="150">
            <td>IndexOutOfRangeException</td>
            <td>数组索引超出范围</td>
        </tr>
        <tr height="25" width="150">
            <td>InvalidCastException</td>
            <td>使用无效的类</td>
        </tr>
        <tr height="25" width="150">
            <td>InvalidOperationException</td>
            <td>方法的调用时间错误</td>
        </tr>
        <tr height="25" width="150">
            <td>MethodAccessException</td>
            <td>试图访问思友或者受保护的方法</td>
        </tr>
        <tr height="25" width="150">
            <td>MissingMemberException</td>
            <td>访问一个无效版本的DLL</td>
        </tr>
        <tr height="25" width="150">
            <td>NotFiniteNumberException</td>
            <td>对象不是一个有效的成员</td>
        </tr>
        <tr height="25" width="150">
            <td>NotSupportedException</td>
            <td>调用的方法在类中没有实现</td>
        </tr>
        <tr height="25" width="150">
            <td>NullReferenceException</td>
            <td>试图使用一个未分配的引用</td>
        </tr>
        <tr height="25" width="150">
            <td>OutOfMemoryException</td>
            <td>内存空间不够</td>
        </tr>
        <tr height="25" width="150">
            <td>PlatformNotSupportedException</td>
            <td>平台不支持某个特定属性时抛出该错误</td>
        </tr>
        <tr height="25" width="150">
            <td>StackOverflowException</td>
            <td>堆栈溢出</td>
        </tr>
    </tbody>
</table>
</div>
<p align="left"><span style="color: rgb(153, 51, 0);"><span style="color: rgb(153, 51, 0);">Exception：所有异常对象的基类。<br />
SystemException：运行时产生的所有错误的基类。<br />
IndexOutOfRangeException：当一个数组的下标超出范围时运行时引发。<br />
NullReferenceException：当一个空对象被引用时运行时引发。<br />
InvalidOperationException：当对方法的调用对对象的当前状态无效时，由某些方法引发。 </span></span><br />
<span style="color: rgb(153, 51, 0);">ArgumentException：所有参数异常的基类。<br />
ArgumentNullException：在参数为空（不允许）的情况下，由方法引发。<br />
ArgumentOutOfRangeException：当参数不在一个给定范围之内时，由方法引发。<br />
InteropException：目标在或发生在CLR外面环境中的异常的基类。<br />
ComException：包含COM类的HRESULT信息的异常。<br />
SEHException：封装Win32结构异常处理信息的异常。<br />
SqlException：封装了SQL操作异常。</span></p>]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/程序研发/135.htm</link>
			<title><![CDATA[c#的public,protected,private,internal,protected图解]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[程序人生]]></category>
			<pubDate>Mon,04 May 2009 14:37:06 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=135</guid>
		<description><![CDATA[<pre>
public:  对任何类和成员都公开, 无限制访问;
<span style="color: rgb(255, 0, 255);">protected:</span> 仅仅对该类以及该类的派生类公开;
private: 仅仅对该类公开;
<span style="color: rgb(255, 0, 255);">internal:</span> 只能值包含该类的程序集中访问该类(只是单独的项目,而不是整个解决方案);
<span style="color: rgb(255, 0, 255);">protected internal:</span> 只能在本类,派生类或者包含该类的程序集中访问.</pre>
<img border="0" src="http://images.cnblogs.com/cnblogs_com/weihai2003/p200882212174.jpg" alt="" />]]></description>
		</item>
		
			<item>
			<link>http://lvzz.zwms.net/article/程序研发/133.htm</link>
			<title><![CDATA[C#中new和override的区别]]></title>
			<author>lvzz.net@gmail.com(bczwx)</author>
			<category><![CDATA[程序人生]]></category>
			<pubDate>Fri,10 Apr 2009 15:21:32 +0800</pubDate>
			<guid>http://lvzz.zwms.net/default.asp?id=133</guid>
		<description><![CDATA[<p>在C#中实现重写方法，可以用new和override两个关键字来实现，究竟他们之间有什么区别呢？下面，我以例子来说明他们之间的微妙区别：<br />
</p>
<div style="border: 1px solid blue; background-color: rgb(255, 255, 225);"><br />
<font color="#0000ff">public class</font> GrandClass<font color="#339966"><font color="#008000">//基类</font><br />
</font>{<br />
<font color="#0000ff"><font color="#000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  </font>public</font> GrandClass()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Console.WriteLine(&quot;In GrandClass.Constructor&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  <font color="#0000ff">public virtual void</font> Method()<font color="#008000">//用virtual才可以在子类中用override,而new不需要这样</font><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Console.WriteLine(&quot;In GrandClass.Method()&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br />
}<br />
<br />
<font color="#0000ff">public class</font> ParentClass:GrandClass<font color="#008000">//继承基类,看看override状态<br />
</font>{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">public</font> ParentClass()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Console.WriteLine(&quot;In ParentClass.Constructor&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">public override void</font> Method()<font color="#008000">//使用override,是说把基类的方法重新定义<br />
</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Console.WriteLine(&quot;In ParentClass.Method() use override&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br />
}<br />
<br />
<font color="#0000ff">public class</font> NewParentClass:GrandClass<font color="#008000">//继承基类,看看new状态</font><br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">public</font> NewParentClass()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Console.WriteLine(&quot;In NewParentClass.Constructor&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#0000ff">new public void</font> Method()<font color="#008000">//使用new,不是说用到基类的方法,而是重新定义一个子类方法,只不过,方法名称与基类相同</font><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  {<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Console.WriteLine(&quot;In NewParentClass.Method()&quot;);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  }<br />
}</div>
<br />
<p>　　下面的调用代码:</p>
<br />
<div style="border: 1px solid blue; background-color: rgb(255, 255, 225);"><br />
<font color="#0000ff">static void</font> Main() <br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  GrandClass Parent=(GrandClass)<font color="#0000ff">new</font> ParentClass();<font color="#008000">//用override子类加框一个基类对象句柄<br />
</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  Parent.Method();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  GrandClass NewParent=(GrandClass)<font color="#0000ff">new</font> NewParentClass();<font color="#008000">//用new子类加框一个基类对象句柄</font><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  NewParent.Method();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  NewParentClass NewParent1=<font color="#0000ff">new</font> NewParentClass();<font color="#008000">//一个子类句柄<br />
</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  NewParent1.Method();<br />
}</div>
<br />
<p>　　结果是这样的:</p>
<br />
<div style="border: 1px solid blue; background-color: rgb(255, 255, 225);"><br />
<font color="#800080">[1]</font>In GrandClass.Constructor<br />
<font color="#800080">[2]</font>In ParentClass.Constructor<br />
<font color="#800080">[3]</font>In ParentClass.Method() use override<br />
<font color="#800080">[4]</font>In GrandClass.Constructor<br />
<font color="#800080">[5]</font>In NewParentClass.Constructor<br />
<font color="#800080">[6]</font>In GrandClass.Method()<br />
<font color="#800080">[7]</font>In GrandClass.Constructor<br />
<font color="#800080">[8]</font>In NewParentClass.Constructor<br />
<font color="#800080">[9]</font>In NewParentClass.Method()</div>
<br />
<p>　　结果前的序号是我自己加的.为了以下的分析:</p>
<br />
<font color="#800080">　　[1]</font>
<p>,</p>
<font color="#800080">[2]</font>
<p>两句是GrandClass Parent=(GrandClass)</p>
<font color="#0000ff">new</font>
<p>ParentClass();的结果.(注意一下子类构建器与基类构建器的初始化顺序)</p>
<br />
<font color="#800080">　　[3]</font>
<p>是Parent.Method();结果.</p>
<br />
<font color="#800080">　　[4]</font>
<p>,</p>
<font color="#800080">[5]</font>
<p>两句是GrandClass NewParent=(GrandClass)</p>
<font color="#0000ff">new</font>
<p>NewParentClass();的结果.</p>
<br />
<font color="#800080">　　[6]</font>
<p>是NewParent.Method();的结果.</p>
<br />
<font color="#800080">　　[7]</font>
<p>,</p>
<font color="#800080">[8]</font>
<p>两句是GrandClass NewParent1=(GrandClass)</p>
<font color="#0000ff">new</font>
<p>NewParentClass();的结果.</p>
<br />
<font color="#800080">　　[9]</font>
<p>是NewParent1.Method();的结果.</p>
<br />
<br />
<p>　　这里我们可以看到,同样是用子类的对象构造一个基类句柄.结果却很明显,可以看到</p>
<font color="#800080">[3]</font>
<p>和</p>
<font color="#800080">[6]</font>
<p>的区别.</p>
<font color="#800080">[3]</font>
<p>调用了子类的Method(),而</p>
<font color="#800080">[6]</font>
<p>调用了基类的Method().</p>
<br />
<p>　　这说明,</p>
<font color="#0000ff">override</font>
<p>可以覆盖基类的方法,让基类的方法以子类的内容实现,而</p>
<font color="#0000ff">new</font>
<p>不用来覆盖基类的方法,而是全新定义一个子类的方法,这个方法只属于子类,与基类的方法无关,只是名字上相同而已.</p>
<br />
<p>而这一例子的基础是建立在用子类对象加框成基类对象的,目的是实现用基类句柄调用子类方法,以实现重载的多形性.</p>
<br />
<p>　　如果想调用子类的</p>
<font color="#0000ff">new</font>
<p>方法,用子类的句柄(绝对不能用基类句柄)来调用.结果</p>
<font color="#800080">[9]</font>
<p>可以看出来.</p>
<br />
<p>　　用</p>
<font color="#0000ff">new</font>
<p>是在为子类定义方法名时,实在没有办法定义方法名的情况才与基类的方法相同,但这个方法只在子类中起到作用,而不影响基类的方法.也就是说,</p>
<font color="#0000ff">new</font>
<p>方法就是子类新定义的方法.用</p>
<font color="#0000ff">override</font>
<p>是直正意义上的重载.&nbsp;</p>
<br />]]></description>
		</item>
		
</channel>
</rss>
