<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>博客园-&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CQSPACE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;</title><link>http://www.cnblogs.com/cyq1162/</link><description>一年又一年,日子都是这么过来
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;等待秋天的落叶</description><language>zh-cn</language><lastBuildDate>Sat, 26 Jul 2008 06:26:33 GMT</lastBuildDate><pubDate>Sat, 26 Jul 2008 06:26:33 GMT</pubDate><ttl>60</ttl><item><title>带线的无限级下拉树列表</title><link>http://www.cnblogs.com/cyq1162/archive/2008/04/17/1157507.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Thu, 17 Apr 2008 02:20:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2008/04/17/1157507.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/1157507.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2008/04/17/1157507.html#Feedback</comments><slash:comments>20</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/1157507.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/1157507.html</trackback:ping><description><![CDATA[摘要: 好多年没写文章了这里就分享点自己原创的一点破代码,效果如图下:本人的提供的代码如下:usingSystem;usingSystem.Collections.Generic;usingSystem.Text;usingSystem.Web.UI.WebControls;namespaceInterface.Common{publicinterfaceIDropDownTree:IDisposable&nbsp;&nbsp;<a href='http://www.cnblogs.com/cyq1162/archive/2008/04/17/1157507.html'>阅读全文</a><img src ="http://www.cnblogs.com/cyq1162/aggbug/1157507.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41316/" target="_blank">[新闻]腾讯CEO马化腾:中国互联网业准备再过冬</a>]]></description></item><item><title>委托/事件/线程传参简单理解</title><link>http://www.cnblogs.com/cyq1162/archive/2008/04/16/1155811.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Wed, 16 Apr 2008 03:56:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2008/04/16/1155811.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/1155811.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2008/04/16/1155811.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/1155811.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/1155811.html</trackback:ping><description><![CDATA[<P>写了很多代码,但几乎都没写过委托/事件/线程传参方面应用的代码<BR>因此自己总很容易理解后又遗忘<BR>今天又重温了一下<BR>因此以最简单的方式的代码方式写下来帮助理解<BR><BR>1.线程传参[简单几行代码]<BR>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN>&nbsp;<SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[]&nbsp;args)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(ThreadPool.QueueUserWorkItem(</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;WaitCallback(Program.WritePara),&nbsp;</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">这是传进去的参数</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">))<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">ok:</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.Read();<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN>&nbsp;<SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">protected</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;WritePara(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;para)<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">hello:</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">para);<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN>&nbsp;<SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN>&nbsp;<SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">15</SPAN>&nbsp;<SPAN style="COLOR: #000000"></SPAN></DIV>
<P>2.委托/事件<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;Program<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_25_698_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_25_698_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_25_698_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_25_698_Closed_Text').style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_25_698_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_25_698_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_25_698_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_25_698_Open_Text').style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_25_698_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_25_698_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">delegate</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;CallFunction(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;para);</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">定义委托[和定义方法一个样,简单理解为static&nbsp;换成了delegate]</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">event</SPAN><SPAN style="COLOR: #000000">&nbsp;CallFunction&nbsp;CallEvenHandle;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">定义事件[简单理解,有事件必有委托]</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[]&nbsp;args)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_240_572_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_240_572_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_240_572_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_240_572_Closed_Text').style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_240_572_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_240_572_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_240_572_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_240_572_Open_Text').style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_240_572_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_240_572_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">调用委托,之前定义像方法,这里new了一个实例,和js的new一个function&nbsp;差不多</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CallFunction&nbsp;cf&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;CallFunction(WritePara);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cf.Invoke(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">goodmorning</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">调用事件,打上"+="后按"Tab"键就出来了,简单使用&nbsp;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CallEvenHandle&nbsp;</SPAN><SPAN style="COLOR: #000000">+=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;CallFunction(WritePara);<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CallEvenHandle(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">CYQ</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">Console.Read();</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">protected</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;WritePara(</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;para)<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_635_692_Open_Image onclick="this.style.display='none'; document.getElementById('Codehighlighter1_635_692_Open_Text').style.display='none'; document.getElementById('Codehighlighter1_635_692_Closed_Image').style.display='inline'; document.getElementById('Codehighlighter1_635_692_Closed_Text').style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_635_692_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('Codehighlighter1_635_692_Closed_Text').style.display='none'; document.getElementById('Codehighlighter1_635_692_Open_Image').style.display='inline'; document.getElementById('Codehighlighter1_635_692_Open_Text').style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_635_692_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_635_692_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">hello:</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">+</SPAN><SPAN style="COLOR: #000000">para);<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top></SPAN></DIV><img src ="http://www.cnblogs.com/cyq1162/aggbug/1155811.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41315/" target="_blank">[新闻]F8 Keynote Speech[多图]</a>]]></description></item><item><title>Xml让人郁闷的SelectNodes方法</title><link>http://www.cnblogs.com/cyq1162/archive/2008/02/26/1081889.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Tue, 26 Feb 2008 03:30:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2008/02/26/1081889.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/1081889.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2008/02/26/1081889.html#Feedback</comments><slash:comments>12</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/1081889.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/1081889.html</trackback:ping><description><![CDATA[摘要: SelectNodes(xpath,namespace)方法中<br>无论是xmlDoc.SelectNodes(xpath,namespace) //假设xmlDoc为根节点,整个文档下的查询<br>还是xmlDoc.ChildNodes[i].SelectNodes(xpath,namespace) //节点下的查询<br><br>两个查询的结果一样:都会把整个文档符合xpath语法条件的都给查出来了<br>事实上我们所要的只是要在某一节点下符合xpath语法的结果&nbsp;&nbsp;<a href='http://www.cnblogs.com/cyq1162/archive/2008/02/26/1081889.html'>阅读全文</a><img src ="http://www.cnblogs.com/cyq1162/aggbug/1081889.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41314/" target="_blank">[新闻]奥运核心资源被分食 搜狐央视网谁忽悠谁？</a>]]></description></item><item><title>文件编码</title><link>http://www.cnblogs.com/cyq1162/archive/2007/11/03/947922.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Sat, 03 Nov 2007 07:34:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/11/03/947922.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/947922.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/11/03/947922.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/947922.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/947922.html</trackback:ping><description><![CDATA[<P>前言:<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;记得前不久,我在公司封闭式开发的日子里,我在宿舍的机子,被同学弄得满身病毒,其中之一是病毒在所有的html里者插入了一段iframe<BR>&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;之后我一不小心..编了段小程序来替换掉所有的iframe,当时忘了文件编码问题..<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 现在打开才发现一大堆乱码在里面<BR><BR>现在发现了..当然是要解决了:<BR>简单看了一下文件流读出来的字节.做了简单的文件类型编码判断<BR>代码如下:</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG id=Codehighlighter1_1_143_Open_Image onclick="this.style.display='none'; Codehighlighter1_1_143_Open_Text.style.display='none'; Codehighlighter1_1_143_Closed_Image.style.display='inline'; Codehighlighter1_1_143_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_1_143_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1_143_Closed_Text.style.display='none'; Codehighlighter1_1_143_Open_Image.style.display='inline'; Codehighlighter1_1_143_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_1_143_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_1_143_Open_Text><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;summary&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;获得文件编码<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;/summary&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;param&nbsp;name="content"&gt;</SPAN><SPAN style="COLOR: #008000">文件流的字节数组</SPAN><SPAN style="COLOR: #808080">&lt;/param&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;returns&gt;</SPAN><SPAN style="COLOR: #008000">字符编码</SPAN><SPAN style="COLOR: #808080">&lt;/returns&gt;</SPAN><SPAN style="COLOR: #808080"></SPAN></SPAN><BR><SPAN style="COLOR: #008080">&nbsp;6</SPAN><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding&nbsp;GetFileEncoding(</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[]&nbsp;content)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_215_798_Open_Image onclick="this.style.display='none'; Codehighlighter1_215_798_Open_Text.style.display='none'; Codehighlighter1_215_798_Closed_Image.style.display='inline'; Codehighlighter1_215_798_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_215_798_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_215_798_Closed_Text.style.display='none'; Codehighlighter1_215_798_Open_Image.style.display='inline'; Codehighlighter1_215_798_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_215_798_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_215_798_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(content.Length&nbsp;</SPAN><SPAN style="COLOR: #000000">&gt;</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_265_751_Open_Image onclick="this.style.display='none'; Codehighlighter1_265_751_Open_Text.style.display='none'; Codehighlighter1_265_751_Closed_Image.style.display='inline'; Codehighlighter1_265_751_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_265_751_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_265_751_Closed_Text.style.display='none'; Codehighlighter1_265_751_Open_Image.style.display='inline'; Codehighlighter1_265_751_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_265_751_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_265_751_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">switch</SPAN><SPAN style="COLOR: #000000">&nbsp;(content[</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">])<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_319_737_Open_Image onclick="this.style.display='none'; Codehighlighter1_319_737_Open_Text.style.display='none'; Codehighlighter1_319_737_Closed_Image.style.display='inline'; Codehighlighter1_319_737_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_319_737_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_319_737_Closed_Text.style.display='none'; Codehighlighter1_319_737_Open_Image.style.display='inline'; Codehighlighter1_319_737_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_319_737_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_319_737_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">case</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">104</SPAN><SPAN style="COLOR: #000000">:<BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.Default;<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">case</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">255</SPAN><SPAN style="COLOR: #000000">:<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.Unicode;<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">case</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">254</SPAN><SPAN style="COLOR: #000000">:<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.BigEndianUnicode;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">case</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">239</SPAN><SPAN style="COLOR: #000000">:<BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.UTF8;<BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">default</SPAN><SPAN style="COLOR: #000000">:<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.Default;<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">24</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.Default;<BR></SPAN><SPAN style="COLOR: #008080">25</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN></DIV>这里只简单做了一下.有更复杂,自己扩展去吧!<BR><BR>反正代码都写到了..再给出两段文件的读和写吧<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Codehighlighter1_1_232_Open_Image onclick="this.style.display='none'; Codehighlighter1_1_232_Open_Text.style.display='none'; Codehighlighter1_1_232_Closed_Image.style.display='inline'; Codehighlighter1_1_232_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_1_232_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1_232_Closed_Text.style.display='none'; Codehighlighter1_1_232_Open_Image.style.display='inline'; Codehighlighter1_1_232_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN id=Codehighlighter1_1_232_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_1_232_Open_Text><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;summary&gt;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;读文件流<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;/summary&gt;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;param&nbsp;name="stream"&gt;</SPAN><SPAN style="COLOR: #008000">文件流;如:File.OpenRead(fileCurrentPath)</SPAN><SPAN style="COLOR: #808080">&lt;/param&gt;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;param&nbsp;name="encoding"&gt;</SPAN><SPAN style="COLOR: #008000">字符编码;如:Encoding.UTF8</SPAN><SPAN style="COLOR: #808080">&lt;/param&gt;</SPAN><SPAN style="COLOR: #008000"><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;returns&gt;</SPAN><SPAN style="COLOR: #008000">流字符串</SPAN><SPAN style="COLOR: #808080">&lt;/returns&gt;</SPAN><SPAN style="COLOR: #808080"></SPAN></SPAN><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;ReadFromStream(FileStream&nbsp;stream,&nbsp;Encoding&nbsp;encoding)<BR><IMG id=Codehighlighter1_323_670_Open_Image onclick="this.style.display='none'; Codehighlighter1_323_670_Open_Text.style.display='none'; Codehighlighter1_323_670_Closed_Image.style.display='inline'; Codehighlighter1_323_670_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_323_670_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_323_670_Closed_Text.style.display='none'; Codehighlighter1_323_670_Open_Image.style.display='inline'; Codehighlighter1_323_670_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_323_670_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_323_670_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[]&nbsp;content&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[stream.Length];<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.Read(content,&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,&nbsp;content.Length);<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.Close();<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(encoding&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding.Default)<BR><IMG id=Codehighlighter1_545_612_Open_Image onclick="this.style.display='none'; Codehighlighter1_545_612_Open_Text.style.display='none'; Codehighlighter1_545_612_Closed_Image.style.display='inline'; Codehighlighter1_545_612_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_545_612_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_545_612_Closed_Text.style.display='none'; Codehighlighter1_545_612_Open_Image.style.display='inline'; Codehighlighter1_545_612_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_545_612_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_545_612_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;encoding&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;GetFileEncoding(content);<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;encoding.GetString(content);<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;ReadFromStream(FileStream&nbsp;stream,</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">&nbsp;Encoding&nbsp;encoding)<BR><IMG id=Codehighlighter1_773_1042_Open_Image onclick="this.style.display='none'; Codehighlighter1_773_1042_Open_Text.style.display='none'; Codehighlighter1_773_1042_Closed_Image.style.display='inline'; Codehighlighter1_773_1042_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_773_1042_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_773_1042_Closed_Text.style.display='none'; Codehighlighter1_773_1042_Open_Image.style.display='inline'; Codehighlighter1_773_1042_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_773_1042_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_773_1042_Open_Text><SPAN style="COLOR: #000000">{<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[]&nbsp;content&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[stream.Length];<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.Read(content,&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,&nbsp;content.Length);<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.Close();<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">;<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;encoding&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;GetFileEncoding(content);<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;encoding.GetString(content);<BR><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN></DIV>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">&nbsp;1</SPAN><IMG id=Codehighlighter1_3_281_Open_Image onclick="this.style.display='none'; Codehighlighter1_3_281_Open_Text.style.display='none'; Codehighlighter1_3_281_Closed_Image.style.display='inline'; Codehighlighter1_3_281_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_3_281_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_3_281_Closed_Text.style.display='none'; Codehighlighter1_3_281_Open_Image.style.display='inline'; Codehighlighter1_3_281_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_3_281_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">/**/</SPAN><SPAN id=Codehighlighter1_3_281_Open_Text><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;summary&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;写文件流<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;3</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;/summary&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;param&nbsp;name="stream"&gt;</SPAN><SPAN style="COLOR: #008000">文件流;如:File.OpenWrite(fileCurrentPath)</SPAN><SPAN style="COLOR: #808080">&lt;/param&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;5</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;param&nbsp;name="encoding"&gt;</SPAN><SPAN style="COLOR: #008000">字符编码;如:Encoding.UTF8</SPAN><SPAN style="COLOR: #808080">&lt;/param&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;param&nbsp;name="Text"&gt;</SPAN><SPAN style="COLOR: #008000">要写的字符串</SPAN><SPAN style="COLOR: #808080">&lt;/param&gt;</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #008080">&nbsp;7</SPAN><SPAN style="COLOR: #008000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #808080">///</SPAN><SPAN style="COLOR: #008000">&nbsp;</SPAN><SPAN style="COLOR: #808080">&lt;returns&gt;</SPAN><SPAN style="COLOR: #008000">bool</SPAN><SPAN style="COLOR: #808080">&lt;/returns&gt;</SPAN><SPAN style="COLOR: #808080"></SPAN></SPAN><BR><SPAN style="COLOR: #008080">&nbsp;8</SPAN><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">bool</SPAN><SPAN style="COLOR: #000000">&nbsp;WriteToStream(FileStream&nbsp;stream,&nbsp;Encoding&nbsp;encoding,&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;Text)<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_382_765_Open_Image onclick="this.style.display='none'; Codehighlighter1_382_765_Open_Text.style.display='none'; Codehighlighter1_382_765_Closed_Image.style.display='inline'; Codehighlighter1_382_765_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_382_765_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_382_765_Closed_Text.style.display='none'; Codehighlighter1_382_765_Open_Image.style.display='inline'; Codehighlighter1_382_765_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_382_765_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_382_765_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">try</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_412_679_Open_Image onclick="this.style.display='none'; Codehighlighter1_412_679_Open_Text.style.display='none'; Codehighlighter1_412_679_Closed_Image.style.display='inline'; Codehighlighter1_412_679_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_412_679_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_412_679_Closed_Text.style.display='none'; Codehighlighter1_412_679_Open_Image.style.display='inline'; Codehighlighter1_412_679_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_412_679_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_412_679_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top><BR></SPAN><SPAN style="COLOR: #008080">13</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">byte</SPAN><SPAN style="COLOR: #000000">[]&nbsp;content&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;encoding.GetBytes(Text.Replace(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">\r\n</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">));<BR></SPAN><SPAN style="COLOR: #008080">14</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.SetLength(content.Length);<BR></SPAN><SPAN style="COLOR: #008080">15</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.Write(content,&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">,&nbsp;content.Length);<BR></SPAN><SPAN style="COLOR: #008080">16</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stream.Close();<BR></SPAN><SPAN style="COLOR: #008080">17</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">true</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">18</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">19</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">catch</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">20</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_711_755_Open_Image onclick="this.style.display='none'; Codehighlighter1_711_755_Open_Text.style.display='none'; Codehighlighter1_711_755_Closed_Image.style.display='inline'; Codehighlighter1_711_755_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><IMG id=Codehighlighter1_711_755_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_711_755_Closed_Text.style.display='none'; Codehighlighter1_711_755_Open_Image.style.display='inline'; Codehighlighter1_711_755_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN id=Codehighlighter1_711_755_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_711_755_Open_Text><SPAN style="COLOR: #000000">{<BR></SPAN><SPAN style="COLOR: #008080">21</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">false</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080">22</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">23</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN></DIV><BR>以上代码没有版权,想用拿去用,想改拿去改!<img src ="http://www.cnblogs.com/cyq1162/aggbug/947922.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41313/" target="_blank">[新闻]微软推新型搜索技术"BrowseRank"挑战谷歌</a>]]></description></item><item><title>数据绑定控件单选框</title><link>http://www.cnblogs.com/cyq1162/archive/2007/11/02/947100.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Fri, 02 Nov 2007 08:08:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/11/02/947100.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/947100.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/11/02/947100.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/947100.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/947100.html</trackback:ping><description><![CDATA[<P>应某人要求,简单写一下<BR>这里用DataList举个例子:<BR>如html代码如下:<BR>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #008080">1</SPAN><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">asp:DataList&nbsp;</SPAN><SPAN style="COLOR: #ff0000">ID</SPAN><SPAN style="COLOR: #0000ff">="dlstClubTheme"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;runat</SPAN><SPAN style="COLOR: #0000ff">="server"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;RepeatColumns</SPAN><SPAN style="COLOR: #0000ff">="2"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;RepeatLayout</SPAN><SPAN style="COLOR: #0000ff">="table"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">ItemTemplate</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">asp:Label&nbsp;</SPAN><SPAN style="COLOR: #ff0000">ID</SPAN><SPAN style="COLOR: #0000ff">="lbLogoPath"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;runat</SPAN><SPAN style="COLOR: #0000ff">="server"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Style</SPAN><SPAN style="COLOR: #0000ff">="display:&nbsp;none;"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;Text</SPAN><SPAN style="COLOR: #0000ff">='&lt;%#&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Eval("LogoPath")&nbsp;%</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">'&gt;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">asp:Label</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">span&nbsp;</SPAN><SPAN style="COLOR: #ff0000">style</SPAN><SPAN style="COLOR: #0000ff">="padding:&nbsp;5px;"</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">5</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_533_554_Open_Image onclick="this.style.display='none'; Codehighlighter1_533_554_Open_Text.style.display='none'; Codehighlighter1_533_554_Closed_Image.style.display='inline'; Codehighlighter1_533_554_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_533_554_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_533_554_Closed_Text.style.display='none'; Codehighlighter1_533_554_Open_Image.style.display='inline'; Codehighlighter1_533_554_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">img&nbsp;</SPAN><SPAN style="COLOR: #ff0000">src</SPAN><SPAN style="COLOR: #0000ff">="&lt;%#&nbsp;Eval("</SPAN><SPAN style="COLOR: #ff0000">Thumbnail")&nbsp;%</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">"&nbsp;width="320"&nbsp;height="63"&nbsp;alt="</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_533_554_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_533_554_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">#&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">Eval</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Description</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000">"&nbsp;/&gt;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">span</SPAN><SPAN style="COLOR: #0000ff">&gt;&lt;</SPAN><SPAN style="COLOR: #800000">br&nbsp;</SPAN><SPAN style="COLOR: #0000ff">/&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;</SPAN><SPAN style="COLOR: #800000">input&nbsp;</SPAN><SPAN style="COLOR: #ff0000">id</SPAN><SPAN style="COLOR: #0000ff">="rbtnClubTheme"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;type</SPAN><SPAN style="COLOR: #0000ff">="radio"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;name</SPAN><SPAN style="COLOR: #0000ff">="rbtnClubTheme"</SPAN><SPAN style="COLOR: #ff0000">&nbsp;value</SPAN><SPAN style="COLOR: #0000ff">='&lt;%#&nbsp;</SPAN><SPAN style="COLOR: #ff0000">Eval("LogoPath")&nbsp;%</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000">'&nbsp;/&gt;<BR></SPAN><SPAN style="COLOR: #008080">7</SPAN><SPAN style="COLOR: #000000"><IMG id=Codehighlighter1_784_798_Open_Image onclick="this.style.display='none'; Codehighlighter1_784_798_Open_Text.style.display='none'; Codehighlighter1_784_798_Closed_Image.style.display='inline'; Codehighlighter1_784_798_Closed_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" align=top><IMG id=Codehighlighter1_784_798_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_784_798_Closed_Text.style.display='none'; Codehighlighter1_784_798_Open_Image.style.display='inline'; Codehighlighter1_784_798_Open_Text.style.display='inline';" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">&lt;%</SPAN><SPAN id=Codehighlighter1_784_798_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><IMG src="http://www.cnblogs.com/images/dot.gif"></SPAN><SPAN id=Codehighlighter1_784_798_Open_Text><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">#&nbsp;</SPAN><SPAN style="COLOR: #0000ff; BACKGROUND-COLOR: #f5f5f5">Eval</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">(</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">Name</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">"</SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #f5f5f5">)&nbsp;</SPAN></SPAN><SPAN style="COLOR: #000000; BACKGROUND-COLOR: #ffff00">%&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">ItemTemplate</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN><SPAN style="COLOR: #000000"><BR></SPAN><SPAN style="COLOR: #008080">9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">&lt;/</SPAN><SPAN style="COLOR: #800000">asp:DataList</SPAN><SPAN style="COLOR: #0000ff">&gt;</SPAN></DIV>单选框是rbtnClubTheme这个,关键点在于,把你想操作的东西,绑定到value去<BR>后台取值操作如下:<BR>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG src="http://www.cnblogs.com/images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;LogoPath&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;Request[</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">rbtnClubTheme</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">];</SPAN></DIV><BR>打完..收工...<img src ="http://www.cnblogs.com/cyq1162/aggbug/947100.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41312/" target="_blank">[新闻]2008年7月26日IT博客精选</a>]]></description></item><item><title>js键盘各键对应的代码 </title><link>http://www.cnblogs.com/cyq1162/archive/2007/09/16/894476.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Sat, 15 Sep 2007 19:22:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/09/16/894476.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/894476.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/09/16/894476.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/894476.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/894476.html</trackback:ping><description><![CDATA[<DIV class="Article_Text Article_Text_Style" id=system_article_content>
<P>描述\r <BR>0x1 鼠标左键\r <BR>0x2 鼠标右键\r <BR>0x3 CANCEL 键\r <BR>0x4 鼠标中键\r <BR>0x8 BACKSPACE 键\r <BR>0x9 TAB 键\r <BR>0xC CLEAR 键\r <BR>0xD ENTER 键\r <BR>0x10 SHIFT 键\r <BR>0x11 CTRL 键\r <BR>0x12 MENU 键\r <BR>0x13 PAUSE 键\r <BR>0x14 CAPS LOCK 键\r <BR>0x1B ESC 键\r <BR>0x20 SPACEBAR 键\r <BR>0x21 PAGE UP 键\r <BR>0x22 PAGE DOWN 键\r <BR>0x23 END 键\r <BR>0x24 HOME 键\r <BR>0x25 LEFT ARROW 键\r <BR>0x26 UP ARROW 键\r <BR>0x27 RIGHT ARROW 键\r <BR>0x28 DOWN ARROW 键\r <BR>0x29 SELECT 键\r <BR>0x2A PRINT SCREEN 键\r <BR>0x2B EXECUTE 键\r <BR>0x2C SNAPSHOT 键\r <BR>0x2D INSERT 键\r <BR>0x2E DELETE 键\r <BR>0x2F HELP 键\r <BR>0x90 NUM LOCK 键\r <BR>A 至 Z 键与 A – Z 字母的 ASCII 码相同： <BR>值 描述\r <BR>65 A 键\r <BR>66 B 键\r <BR>67 C 键\r <BR>68 D 键\r <BR>69 E 键\r <BR>70 F 键\r <BR>71 G 键\r <BR>72 H 键\r <BR>73 I 键\r <BR>74 J 键\r <BR>75 K 键\r <BR>76 L 键\r <BR>77 M 键\r <BR>78 N 键\r <BR>79 O 键\r <BR>80 P 键\r <BR>81 Q 键\r <BR>82 R 键\r <BR>83 S 键\r <BR>84 T 键\r <BR>85 U 键\r <BR>86 V 键\r <BR>87 W 键\r <BR>88 X 键\r <BR>89 Y 键\r <BR>90 Z 键\r <BR>0 至 9 键与数字 0 – 9 的 ASCII 码相同： <BR>值 描述\r <BR>48 0 键\r <BR>49 1 键\r <BR>50 2 键\r <BR>51 3 键\r <BR>52 4 键\r <BR>53 5 键\r <BR>54 6 键\r <BR>55 7 键\r <BR>56 8 键\r <BR>57 9 键\r <BR>下列常数代表数字键盘上的键： <BR>值 描述\r <BR>0x60 0 键\r <BR>0x61 1 键\r <BR>0x62 2 键\r <BR>0x63 3 键\r <BR>0x64 4 键\r <BR>0x65 5 键\r <BR>0x66 6 键\r <BR>0x67 7 键\r <BR>0x68 8 键\r <BR>0x69 9 键\r <BR>0x6A MULTIPLICATION SIGN (*) 键\r <BR>0x6B PLUS SIGN (+) 键\r <BR>0x6C ENTER 键\r <BR>0x6D MINUS SIGN (–) 键\r <BR>0x6E DECIMAL POINT (.) 键\r <BR>0x6F DIVISION SIGN (/) 键\r <BR>下列常数代表功能键： <BR>值 描述\r <BR>0x70 F1 键\r <BR>0x71 F2 键\r <BR>0x72 F3 键\r <BR>0x73 F4 键\r <BR>0x74 F5 键\r <BR>0x75 F6 键\r <BR>0x76 F7 键\r <BR>0x77 F8 键\r <BR>0x78 F9 键\r <BR>0x79 F10 键\r <BR>0x7A F11 键\r <BR>0x7B F12 键\r <BR>0x7C F13 键\r <BR>0x7D F14 键\r <BR>0x7E F15 键\r <BR>0x7F F16 键\r </P>
<P>例子:数字</P>
<P>if(event.keyCode&lt;48 || event.keyCode&gt;57 ){this.value=xxxx;}</P></DIV><img src ="http://www.cnblogs.com/cyq1162/aggbug/894476.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41311/" target="_blank">[新闻]微软每年向Apache捐10万美元支持开源软件</a>]]></description></item><item><title>Left/right join 和inner join 区别</title><link>http://www.cnblogs.com/cyq1162/archive/2007/08/25/869563.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Sat, 25 Aug 2007 10:24:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/08/25/869563.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/869563.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/08/25/869563.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/869563.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/869563.html</trackback:ping><description><![CDATA[<DIV class="Article_Text Article_Text_Style" id=system_article_content>举个例子： <BR>假设ａ表和ｂ表的<NOBR oncontextmenu="return false;" id=key2 style="COLOR: #6600ff; BORDER-BOTTOM: #6600ff 1px dotted; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" target="_blank">数据</NOBR>是这样的。 <BR>a b <BR>id name　　id stock　 <BR>1　　a 1 15 <BR>2 b 2 50 <BR>3 c 　 <BR><BR>select * from a inner join b on a.id=b.id <BR>这个<NOBR oncontextmenu="return false;" id=key3 onmouseover="kwE(event,3, this);" style="COLOR: #6600ff; BORDER-BOTTOM: #6600ff 1px dotted; BACKGROUND-COLOR: transparent; TEXT-DECORATION: underline" target="_blank">语法</NOBR>是连接查询中的内连接，它产生的结果是 <BR>两个表相匹配的记录出现在结果列表中。 <BR>根据上面的表，出现的结果是这样的 <BR>a.id name b.id stock <BR>1　　 a 1 15 <BR>2 b 2 50 <BR>---------------------------- <BR>select * from a,b where a.id=b.id <BR>这个语法是内连接的另外一种写法，其执行结果与inner join 一样 <BR><BR>-------------------------------- <BR><BR>select * from a left/right join b on a.id=b.id <BR>这个是外连接语法中的左外连接或右外连接 <BR>如果是左外连接的话，它将显示ａ表的所有记录， <BR>select a.*,b.* from a left join b on a.id=b.id <BR>查询的结果是这样的： <BR>a.id name b.id stock <BR>1　　 a 1 15 <BR>2 b 2 50 <BR>3 c null null　 <BR>-------------------------------------------- <BR>如果是右外连接的话，它将显示ｂ表的所有记录， <BR>select a.*,b.* from a right join b on a.id=b.id <BR>查询的结果是这样的： <BR>a.id name b.id stock <BR>1　　 a 1 15 <BR>2 b 2 50 <BR></DIV><img src ="http://www.cnblogs.com/cyq1162/aggbug/869563.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41310/" target="_blank">[新闻]AOL将关闭3个网站以降低成本 集中发力广告</a>]]></description></item><item><title>创建自定义数据源 </title><link>http://www.cnblogs.com/cyq1162/archive/2007/08/22/865307.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Wed, 22 Aug 2007 06:15:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/08/22/865307.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/865307.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/08/22/865307.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/865307.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/865307.html</trackback:ping><description><![CDATA[摘要: 看到一则使用CollectionBase为父类创建自定义数据源的例子:usingSystem;namespace自定义数据源{/**////&lt;summary&gt;///自定义数据源///&lt;/summary&gt;publicclasscusdatasource:System.Collections.CollectionBase{publiccusdatasource(){for(in&nbsp;&nbsp;<a href='http://www.cnblogs.com/cyq1162/archive/2007/08/22/865307.html'>阅读全文</a><img src ="http://www.cnblogs.com/cyq1162/aggbug/865307.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41309/" target="_blank">[新闻]谷歌网页索引数量突破1万亿个</a>]]></description></item><item><title>值类型与引用类型（下)</title><link>http://www.cnblogs.com/cyq1162/archive/2007/08/16/858030.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Thu, 16 Aug 2007 05:21:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/08/16/858030.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/858030.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/08/16/858030.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/858030.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/858030.html</trackback:ping><description><![CDATA[<P>本文将介绍以下内容： </P>
<UL>
<LI>类型的基本概念&nbsp; 
<LI>值类型深入 
<LI>引用类型深入 
<LI>值类型与引用类型的比较及应用 </LI></UL>
<P><STRONG>[下载]</STRONG>：[<A href="/Files/anytao/Anytao_Demo_10.rar"><FONT color=#0000cc>类型示例代码</FONT></A>]</P>
<P align=right><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/8a4eb4e1-1f3a-45c0-8573-a1bd995d0032/Banner_2007_044.jpg" atomicselection="true"></A>&nbsp;</P>
<P><STRONG>1.&nbsp;引言</STRONG></P>
<P>值类型与引用类型的话题经过了两个回合（[<A href="/anytao/archive/2007/05/23/must_net_08.html"><FONT color=#669966>第八回：品味类型---值类型与引用类型（上）－内存有理</FONT></A>]和[<A href="/anytao/archive/2007/05/28/must_net_09.html"><FONT color=#669966>第九回：品味类型---值类型与引用类型（中）－规则无边</FONT></A>]）的讨论和切磋，我们就基本的理解层面来说已经差不多了，但是对这一部分的进一步把握和更深刻的理解还要继续和深化，因为我自己就在两篇发布之际，我就得到<A href="http://ninputer.cnblogs.com/"><FONT color=#669966>装配脑袋</FONT></A>兄的不倦指导，之后又查阅了很多的资料发现类型在.NET或者说语言基础中何其重要的内涵和深度，因此关于这个话题的讨论还没有停止，以后我将继续分享自己的所得与所感。</P>
<P>不过作为一个阶段，本文将值类型和引用类型的讨论从应用示例角度来进一步做以延伸，可以看作是对前两回的补充性探讨。我们从类型定义、实例创建、参数传递、类型判等、垃圾回收等几个方面来简要的对上两回的内容做以剖析，并以一定的IL语言和内存机制来说明，期望进一步加深我们的理解和分析。&nbsp; </P>
<P><STRONG>2. 以代码剖析</STRONG> </P>
<P>下面，我们以一个经典的值类型和引用类型对比的示例来剖析，其区别和实质。在剖析的过程中，我们主要以执行分析（主要是代码注释）、内存分析（主要是图例说明）和IL分析（主要是IL代码简析）三个方面来逐知识点解析，最后再做以总结描述，这样就可以有更深的理解。 </P>
<P><STRONG>2.1 类型定义</STRONG> </P>
<P>定义简单的值类型MyStruct和引用类型MyClass，在后面的示例中将逐渐完善，完整的代码可以点击下载[类型示例代码]。我们的讨论现在开始， </P>
<UL>
<LI>代码演示 </LI></UL>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;01&nbsp;定义值类型</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;_myNo;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;MyNo<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">&nbsp;{&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;_myNo;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN style="COLOR: #000000">&nbsp;{&nbsp;_myNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;value;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;myNo)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_myNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;myNo;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;ShowNo()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(_myNo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></DIV>
<P>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;02&nbsp;定义引用类型</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;MyClass<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">private</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;_myNo;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;MyNo<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">get</SPAN><SPAN style="COLOR: #000000">&nbsp;{&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;_myNo;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">set</SPAN><SPAN style="COLOR: #000000">&nbsp;{&nbsp;_myNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;value;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;MyClass()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_myNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">0</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;MyClass(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;myNo)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_myNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;myNo;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;ShowNo()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(_myNo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></DIV>
<UL>
<LI>&nbsp;IL分析 </LI></UL><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/8a4eb4e1-1f3a-45c0-8573-a1bd995d0032/10_013.jpg" atomicselection="true"></A>
<P><IMG height=314 alt="" src="http://www.cnblogs.com/images/cnblogs_com/anytao/10_01.jpg" width=500>&nbsp;</P>
<P>分析IL代码可知，静态方法.ctor用来表示实现构造方法的定义，其中该段IL代码表示将0赋给字段_myNo。</P>
<P><STRONG>2.2 创建实例、初始化及赋值</STRONG> </P>
<P>接下来，我们完成实例创建和初始化，和简单的赋值操作，然后在内存和IL分析中发现其实质。 </P>
<UL>
<LI>代码演示 </LI></UL>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Code_Closed_Image_231128 onclick="this.style.display='none'; Code_Closed_Text_231128.style.display='none'; Code_Open_Image_231128.style.display='inline'; Code_Open_Text_231128.style.display='inline';" height=16 alt="" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" width=11 align=top><IMG id=Code_Open_Image_231128 style="DISPLAY: none" onclick="this.style.display='none'; Code_Open_Text_231128.style.display='none'; Code_Closed_Image_231128.style.display='inline'; Code_Closed_Text_231128.style.display='inline';" height=16 alt="" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" width=11 align=top><SPAN id=Code_Closed_Text_231128 style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">创建实例、初始化及赋值</SPAN><SPAN id=Code_Open_Text_231128 style="DISPLAY: none"><BR><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[]&nbsp;args)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">内存分配于线程的堆栈上<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">创建了值为等价"0"的实例</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyStruct&nbsp;myStruct&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">在线程的堆栈上创建了引用，但未指向任何实例</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyClass&nbsp;myClass;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">内存分配于托管堆上</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myClass&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;MyClass();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">在堆栈上修改成员</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myStruct.MyNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">1</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">将指针指向托管堆</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myClass.MyNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">2</SPAN><SPAN style="COLOR: #000000">;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myStruct.ShowNo();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myClass.ShowNo();<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">在堆栈上新建内存，并执行成员拷贝</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyStruct&nbsp;myStruct2&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;myStruct;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">拷贝引用地址</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyClass&nbsp;myClass2&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;myClass;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">在堆栈上修改myStruct成员</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myStruct.MyNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">3</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">在托管堆上修改成员</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myClass.MyNo&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">4</SPAN><SPAN style="COLOR: #000000">;<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myStruct.ShowNo();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myClass.ShowNo();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myStruct2.ShowNo();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;myClass2.ShowNo();&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></SPAN></SPAN></DIV>
<UL>
<LI>内存实况 </LI></UL>
<P>首先是值类型和引用类型的定义，这是一切面向对象的开始，</P>
<P><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/8a4eb4e1-1f3a-45c0-8573-a1bd995d0032/10_023.jpg" atomicselection="true"></A><IMG height=268 alt="" src="http://www.cnblogs.com/images/cnblogs_com/anytao/10_02.jpg" width=500>&nbsp;&nbsp;</P>
<P>&nbsp;然后是初始化过程，</P>
<P><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/8a4eb4e1-1f3a-45c0-8573-a1bd995d0032/10_033.jpg" atomicselection="true"></A><IMG height=268 alt="" src="http://www.cnblogs.com/images/cnblogs_com/anytao/10_03.jpg" width=500>&nbsp;</P>
<P>&nbsp;简单的赋值和拷贝，是最基本的内存操作，不妨看看，</P>
<P><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/8a4eb4e1-1f3a-45c0-8573-a1bd995d0032/10_043.jpg" atomicselection="true"></A><IMG height=268 alt="" src="http://www.cnblogs.com/images/cnblogs_com/anytao/10_04.jpg" width=500>&nbsp;&nbsp; </P>
<P><STRONG>2.3 参数传递</STRONG> </P>
<UL>
<LI>代码演示 </LI></UL>
<P>&nbsp;</P>
<P>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><IMG id=Code_Closed_Image_232321 onclick="this.style.display='none'; Code_Closed_Text_232321.style.display='none'; Code_Open_Image_232321.style.display='inline'; Code_Open_Text_232321.style.display='inline';" height=16 alt="" src="http://www.cnblogs.com/images/OutliningIndicators/ContractedBlock.gif" width=11 align=top><IMG id=Code_Open_Image_232321 style="DISPLAY: none" onclick="this.style.display='none'; Code_Open_Text_232321.style.display='none'; Code_Closed_Image_232321.style.display='inline'; Code_Closed_Text_232321.style.display='inline';" height=16 alt="" src="http://www.cnblogs.com/images/OutliningIndicators/ExpandedBlockStart.gif" width=11 align=top><SPAN id=Code_Closed_Text_232321 style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">参数传递</SPAN><SPAN id=Code_Open_Text_232321 style="DISPLAY: none"><BR><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;04&nbsp;ref和out</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;RefAndOut<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">必须进行初始化，才能使用ref方式传递</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;x&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ValueWithRef(</SPAN><SPAN style="COLOR: #0000ff">ref</SPAN><SPAN style="COLOR: #000000">&nbsp;x);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(x);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">使用out方式传递，不必初始化</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;y;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ValueWithOut(</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">&nbsp;y);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(y);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;oRef&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RefWithRef(</SPAN><SPAN style="COLOR: #0000ff">ref</SPAN><SPAN style="COLOR: #000000">&nbsp;oRef);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(oRef.ToString());<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;owith;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;RefWithOut(</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">&nbsp;owith);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(owith.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;ValueWithRef(</SPAN><SPAN style="COLOR: #0000ff">ref</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">100</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(i.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;ValueWithOut(</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;i)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">200</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(i.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;RefWithRef(</SPAN><SPAN style="COLOR: #0000ff">ref</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;o)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(o.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;RefWithOut(</SPAN><SPAN style="COLOR: #0000ff">out</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">object</SPAN><SPAN style="COLOR: #000000">&nbsp;o)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;o&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;String(</SPAN><SPAN style="COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">a</SPAN><SPAN style="COLOR: #000000">'</SPAN><SPAN style="COLOR: #000000">,&nbsp;</SPAN><SPAN style="COLOR: #000000">10</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(o.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></SPAN></DIV>
<P> </P>
<P>不必多说，就是一个简要阐释，对于参数的传递作者将计划以更多的笔墨来在后面的系列中做以澄清和深入。 </P>
<P><STRONG>2.4 类型转换</STRONG> </P>
<P>类型转换的演示，包括很多个方面，在此我们只以自定义类型转换为例来做以说明，更详细的类型转换可以参考[<A href="/anytao/archive/2007/05/28/must_net_09.html"><FONT color=#669966>第九回：品味类型---值类型与引用类型（中）－规则无边</FONT></A>]的[再论类型转换部分]。 </P>
<UL>
<LI>代码演示 </LI></UL>
<P>首先是值类型的自定义类型转换，</P>
<P>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct<BR>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;01.2&nbsp;自定义类型转：整形-&gt;MyStruct型</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">explicit</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">operator</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct(</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;myNo)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStruct(myNo);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR></SPAN></DIV>
<P><BR>然后是引用类型的自定义类型转换， </P>
<P>&nbsp;</P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;MyClass<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">&nbsp;02.2&nbsp;自定义类型转换：MyClass-&gt;string型</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">implicit</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">operator</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">(MyClass&nbsp;mc)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;mc.ToString();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">override</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;ToString()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">return</SPAN><SPAN style="COLOR: #000000">&nbsp;_myNo.ToString();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}<BR></SPAN></DIV>
<P><BR>最后，我们对自定义的类型做以测试，<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main(</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">[]&nbsp;args)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">#region</SPAN><SPAN style="COLOR: #000000">&nbsp;03.&nbsp;类型转换</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyStruct&nbsp;MyNum;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">int</SPAN><SPAN style="COLOR: #000000">&nbsp;i&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">100</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyNum&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;(MyStruct)i;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">整形显式转换为MyStruct型---</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(i);<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyClass&nbsp;MyCls&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;MyClass(</SPAN><SPAN style="COLOR: #000000">200</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;str&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;MyCls;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">MyClass型隐式转换为string型---</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine(str);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">#endregion</SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #000000"><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR></SPAN></DIV>
<P><STRONG>2.5 类型判等</STRONG> </P>
<P>类型判等主要包括：ReferenceEquals()、Equals()虚方法和静态方法、==操作符等方面，同时注意在值类型和引用类型判等时的不同之处，可以参考[<A href="/anytao/archive/2007/05/28/must_net_09.html"><FONT color=#669966>第九回：品味类型---值类型与引用类型（中）－规则无边</FONT></A>]的[4. 再论类型判等]的简述。 </P>
<P>&nbsp;</P>
<UL>
<LI>代码演示&nbsp; </LI></UL>
<P>// 01 定义值类型<BR>public struct MyStruct<BR>{ </P>
<P>// 01.1 值类型的类型判等<BR>public override bool Equals(object obj)<BR>{<BR>return base.Equals(obj);<BR>} </P>
<P>}&nbsp;&nbsp; </P>
<P>public class MyClass<BR>{ </P>
<P>// 02.1 引用类型的类型判等<BR>public override bool Equals(object obj)<BR>{<BR>return base.Equals(obj);<BR>} </P>
<P>}&nbsp;</P>
<P>public static void Main(string[] args) </P>
<P>{</P>
<P>#region 05 类型判等<BR>Console.WriteLine("类型判等---");<BR>// 05.1 ReferenceEquals判等<BR>//值类型总是返回false，经过两次装箱的myStruct不可能指向同一地址<BR>Console.WriteLine(ReferenceEquals(myStruct, myStruct));<BR>//同一引用类型对象，将指向同样的内存地址<BR>Console.WriteLine(ReferenceEquals(myClass, myClass));<BR>//RefenceEquals认为null等于null，因此返回true<BR>Console.WriteLine(ReferenceEquals(null, null)); </P>
<P>// 05.2 Equals判等<BR>//重载的值类型判等方法，成员大小不同<BR>Console.WriteLine(myStruct.Equals(myStruct2)) ; </P>
<P>//重载的引用类型判等方法，指向引用相同<BR>Console.WriteLine(myClass.Equals(myClass2)); </P>
<P>#endregion </P>
<P>}&nbsp;&nbsp; </P>
<P><STRONG>2.6 垃圾回收</STRONG>&nbsp;&nbsp; </P>
<P>首先，垃圾回收机制，绝对不是三言两语就能交代清楚，分析明白的。因此，本示例只是从最简单的说明出发，对垃圾回收机制做以简单的分析，目的是有始有终的交代实例由创建到消亡的全过程。 </P>
<UL>
<LI>代码演示 </LI></UL>
<P>public static void Main(string[] args)<BR>{</P>
<P>#region 06 垃圾回收的简单阐释<BR>//实例定义及初始化<BR>MyClass mc1 = new MyClass();<BR>//声明但不实体化<BR>MyClass mc2;<BR>//拷贝引用，mc2和mc1指向同一托管地址<BR>mc2 = mc1;<BR>//定义另一实例，并完成初始化<BR>MyClass mc3 = new MyClass();<BR>//引用拷贝，mc1、mc2指向了新的托管地址<BR>//那么原来的地址成为GC回收的对象，在<BR>mc1 = mc3;<BR>mc2 = mc3;<BR>#endregion </P>
<P>}&nbsp;&nbsp; </P>
<UL>
<LI>内存实况 </LI></UL>
<P><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/8a4eb4e1-1f3a-45c0-8573-a1bd995d0032/10_5[3].jpg" atomicselection="true"></A><IMG height=689 alt="" src="http://www.cnblogs.com/images/cnblogs_com/anytao/10_5.jpg" width=500>&nbsp;</P>
<P>GC执行时，会遍历所有的托管堆对象，按照一定的递归遍历算法找出所有的可达对象和不可访问对象，显然本示例中的托管堆A对象没有被任何引用访问，属于不可访问对象，将被列入执行垃圾收集的目标。对象由newobj指令产生，到被GC回收是一个复杂的过程，我们期望在系列的后期对此做以深入浅出的理解。&nbsp; </P>
<P><STRONG>2.7&nbsp;总结陈述</STRONG> </P>
<P>这些示例主要从从基础的方向入手来剖析前前两回中的探讨，不求能够全面而深邃，但求能够一点而及面的展开，技术的魅力正在于千变万化，技术追求者的力求却是从变化中寻求不变，不然我们实质太累了，我想这就是好方法，本系列希望的就是提供一个入口，打开一个方法。示例的详细分析可以下载[<FONT color=#0000ff><A href="/Files/anytao/Anytao_Demo_10.rar"><FONT color=#0000ff>类型示例代码</FONT></A></FONT>]，简单的分析希望能带来丝丝惬意。&nbsp; </P>
<P><STRONG>3. </STRONG><A href="http://www.anytao.com/" target=_blank><FONT color=#669966>结论</FONT></A></P>
<P>值类型和引用类型，要说的，要做的，还有很多。此篇只是一个阶段，更多的深入和探讨我相信还在继续，同时广泛的关注技术力量的成长，是每个人应该进取的空间和道路。</P>
<P>品味类型，为应用之路开辟技术基础。</P>
<P>品味类型，继续探讨还会更多精彩。<BR>------------引用地址:http://blog.csdn.net/netzhou/archive/2007/06/27/1668641.aspx</P><img src ="http://www.cnblogs.com/cyq1162/aggbug/858030.html?type=1" width = "1" height = "1" /><br><br><a href="http://news.cnblogs.com/n/41308/" target="_blank">[新闻]预装 Ubuntu 8.04 的 Dell 笔记本发售</a>]]></description></item><item><title>值类型与引用类型（中)</title><link>http://www.cnblogs.com/cyq1162/archive/2007/08/16/858028.html</link><dc:creator>路过秋天</dc:creator><author>路过秋天</author><pubDate>Thu, 16 Aug 2007 05:19:00 GMT</pubDate><guid>http://www.cnblogs.com/cyq1162/archive/2007/08/16/858028.html</guid><wfw:comment>http://www.cnblogs.com/cyq1162/comments/858028.html</wfw:comment><comments>http://www.cnblogs.com/cyq1162/archive/2007/08/16/858028.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cnblogs.com/cyq1162/comments/commentRss/858028.html</wfw:commentRss><trackback:ping>http://www.cnblogs.com/cyq1162/services/trackbacks/858028.html</trackback:ping><description><![CDATA[<P>本文将介绍以下内容： </P>
<UL>
<LI>类型的基本概念&nbsp; 
<LI>值类型深入 
<LI>引用类型深入 
<LI>值类型与引用类型的比较及应用 </LI></UL>
<P align=right><A href="file:///C:/Users/anytao/AppData/Roaming/Windows%20Live%20Writer/PostSupportingFiles/35ed3e0a-4644-4cb4-91f2-605e35a81289/Banner_2007_048.jpg" atomicselection="true"></A>&nbsp;&nbsp;</P>
<P><STRONG>1.&nbsp;引言</STRONG></P>
<P>上回[<A href="/anytao/archive/2007/05/23/must_net_08.html"><FONT color=#669966>第八回：品味类型---值类型与引用类型（上）－内存有理</FONT></A>]的发布，受到大家的不少关注，我们从内存的角度了解了值类型和引用类型的所以然，留下的任务当然是如何应用类型的不同特点在系统设计、性能优化等方面发挥其作用。因此，本回是对上回有力的补充，同时应朋友的希望，我们尽力从内存调试的角度来着眼一些设计的分析，这样就有助于对这一主题进行透彻和全面的理解，当然这也是下一回的重点。</P>
<P>从内存角度来讨论值类型和引用类型是有理有据的，&nbsp;&nbsp;而从规则的角度来了解值类型和引用类型是无边无际的。本文旨在从上文呼应的角度，来把这个主题彻底的融会贯通，无边无迹的应用，还是来自反复无常的实践，因此对应用我只能说以一个角度来阐释观点，但是肯定不可能力求全局。因此，我们从以下几个角度来完成对值类型与引用类型应用领域的讨论。&nbsp; </P>
<P><STRONG>2. 通用规则与比较</STRONG> </P>
<P><STRONG>通用有规则：</STRONG> </P>
<UL>
<LI>string类型是个特殊的引用类型，它继承自System.Object肯定是个引用类型，但是在应用表现上又凸现出值类型的特点，那么究竟是什么原因呢？例如有如下的一段执行： </LI></UL>
<P>&nbsp;<IMG alt="" src="http://www.cnblogs.com/images/cnblogs_com/anytao/val_ref_demo.jpg" border=0></P>
<P>&nbsp;简单的说是由于string的immutable特性，因此每次对string的改变都会在托管堆中产生一个新的string变量，上述string作为参数传递时，实际上执行了s=s操作，在托管堆中会产生一个新的空间，并执行数据拷贝，所以才有了类似于按值传递的结果。但是根据我们的内存分析可知，string在本质上还是一个引用类型，在参数传递时发生的还是按址传递，不过由于其特殊的恒定特性，在函数内部新建了一个string对象并完成初始化，但是函数外部取不到这个变化的结果，因此对外表现的特性就类似于按值传递。至于string类型的特殊性解释，我推荐<A href="/artech/" target=_blank><FONT color=#669966>Artech</FONT></A>的大作《<A href="/artech/archive/2007/05/06/737130.html" target=_blank><FONT color=#669966>深入理解string和如何高效地使用string</FONT></A>》。</P>
<P>另外，string类型重载了==操作符，在类型比较是比较的是实际的字符串，而不是引用地址，因此有以下的执行结果：<BR></P>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;aString&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">123</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;bString&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">123</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine((aString&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;bString));&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">显示为true，等价于aString.Equals(bString)；</SPAN><SPAN style="COLOR: #008000"><BR></SPAN><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">string</SPAN><SPAN style="COLOR: #000000">&nbsp;cString&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;bString;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cString&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">456</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Console.WriteLine((bString&nbsp;</SPAN><SPAN style="COLOR: #000000">==</SPAN><SPAN style="COLOR: #000000">&nbsp;cString));&nbsp;</SPAN><SPAN style="COLOR: #008000">//</SPAN><SPAN style="COLOR: #008000">显示为false，等价于bString.Equals(cString)；<BR></SPAN></DIV>
<UL>
<LI>通常可以使用Type.IsValueType来判断一个变量的类型是否为值类型，典型的操作为：&nbsp; </LI></UL>
<DIV style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">struct</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStructTester<BR>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;}<BR><BR>&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">class</SPAN><SPAN style="COLOR: #000000">&nbsp;isValueType_Test<BR>&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">public</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">static</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">void</SPAN><SPAN style="COLOR: #000000">&nbsp;Main()<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyStructTester&nbsp;aStruct&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;MyStructTester();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Type&nbsp;type&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;aStruct.GetType();<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: #0000ff">if</SPAN><SPAN style="COLOR: #000000">&nbsp;(type.IsValueType)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&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(</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">{0}&nbsp;belongs&nbsp;to&nbsp;value&nbsp;type.</SPAN><SPAN style="COLOR: #000000">"</SPAN><SPAN style="COLOR: #000000">,&nbsp;aStruct.ToString());<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}</SPAN></DIV>
<UL>
<LI>.NET中以操作符ref和out来标识值类型按引用类型方式传递，其中区别是：ref在参数传递之前必须初始化；而out则在传递前不必初始化，且在传递时必须显式赋值。 
<LI>值