<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>找对象_51obj.cn</title>
	<atom:link href="http://www.51obj.cn/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.51obj.cn</link>
	<description>IT 技术交流博客，致力于前台xhtml、css、js、ajax应用，及后台asp、asp.net程序开发</description>
	<lastBuildDate>Tue, 10 Aug 2010 11:20:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://www.51obj.cn/wp-includes/js/jquery/jquery.js?ver=1.4.2'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>一套完整自定义工作流的实现</title>
		<link>http://www.51obj.cn/?p=934</link>
		<comments>http://www.51obj.cn/?p=934#comments</comments>
		<pubDate>Tue, 10 Aug 2010 11:14:54 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=934</guid>
		<description><![CDATA[&#160; 概述： 本工作流以一套金融软件业务处理流程为例，实现功能包括：流程自定义、步骤自定义、步骤重复次数、步骤类型（顺序/并行）、定义排序功能，完全使用数据库实现，本文将详... 


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>&nbsp;</p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">概述：</strong></span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; ">本工作流以一套金融软件业务处理流程为例，实现功能包括：流程自定义、步骤自定义、步骤重复次数、步骤类型（顺序/并行）、定义排序功能，完全使用数据库实现，本文将详细分析业务流程、系统设计及实现细节。</span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; "><strong style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">术语：</strong></span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; "><a href="http://zh.wikipedia.org/zh-cn/%E5%B7%A5%E4%BD%9C%E6%B5%81" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; color: black; text-decoration: underline; " target="_blank">工作流（Workflow</a>）[1]，是对工作流程及其各操作步骤之间业务规则的抽象、概括、描述。工作流建模，即将工作流程中的工作如何前后组织在一起的逻辑和规则在计算机中以恰当的模型进行表示并对其实施计算。工作流要解决的主要问题是：为实现某个业务目标，在多个参与者之间，利用计算机，按某种预定规则自动传递文档、信息或者任务。工作流管理系统（Workflow Management System, WfMS）的主要功能是通过计算机技术的支持去定义、执行和管理工作流，协调工作流执行过程中工作之间以及群体成员之间的信息交互。工作流需要依靠工作流管理系统来实现。</span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; ">流程：工作流包含多个工作流程，处理时可任选一种流程进行处理，其包含步骤信息；</span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; ">步骤：流程中每一环节的名称，某一流程将包含多个步骤（其他工作流中也称为节点）。</span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; "><br />
	</span></p>
<p style="margin-top: 5px; margin-right: auto; margin-bottom: 5px; margin-left: auto; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-indent: 0px; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: verdana, 'ms song', 宋体, Arial, 微软雅黑, Helvetica, sans-serif; font-size: 14px; line-height: 21px; ">本文原发于博客园，原文见（<span class="Apple-style-span" style="font-family: Arial, Verdana, sans-serif; line-height: normal; font-size: 12px; color: rgb(34, 34, 34); "><a href="http://www.cnblogs.com/walkingp/archive/2010/08/09/1795527.html" target="_blank">http://www.cnblogs.com/walkingp/archive/2010/08/09/1795527.html</a>）</span></span></p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=934</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL打印中指定表的所有列名</title>
		<link>http://www.51obj.cn/?p=919</link>
		<comments>http://www.51obj.cn/?p=919#comments</comments>
		<pubDate>Fri, 23 Jul 2010 04:01:11 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=919</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
还记得以前做asp时，设计access数据库：一边添加字段，一边打开一个notepad记录，然后在代码里把这些字段都加上。 现在可以使用SQL将表的所有列名显示，代码如下： &#160; DECLARE @colName varchar(500... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=547' rel='bookmark' title='Permanent Link: asp.net中恢复数据库的问题'>asp.net中恢复数据库的问题</a> <small>项目中使用到了恢复数据库的功能。直接使用RESTORE DATABASE table FROM DISK=&#39;Path&#39;;结果出现了不少问题。 尚未备份数据库的日志尾部 异常详细信息: System.Data.SqlClient.SqlException: 尚未备份数据库 &quot;HopeLoan2009&quot;...</small></li>
<li><a href='http://www.51obj.cn/?p=911' rel='bookmark' title='Permanent Link: SQL中以迪卡尔积插入数据'>SQL中以迪卡尔积插入数据</a> <small>很久没有写文章了，今天做项目时温习了一下SQL。现在有三张表S_action_info、E_grade_info、S_action_grade，其中第三张表为中间表，用于保存前两张表多对多关系。 数据结构图如下： 其它字段可不必考虑，重要的有前两张表的主键，和第三张表中相对应的外键。前两张表中已有部分数据，需要对第三张表进行一些测试数据的插入。于是SQL语句如下： ?View Code SQL/* *若建立存储过程 IF EXISTS(SELECT name...</small></li>
<li><a href='http://www.51obj.cn/?p=837' rel='bookmark' title='Permanent Link: 闲来没事发一个C#做的一个东西'>闲来没事发一个C#做的一个东西</a> <small>使用.net2.0开发，可查看系统服务信息、系统进程信息及软件安装信息，其中根据进程查看进程功能有待进一步完善；软件安装信息根据注册表信息来提取，由于有些软件图标无法获得，因此获得的软件列表并不完全。 源码完全开放，使用VS2005 SP1打开。 ?View Code CSHARP /// &lt;summary&gt; /// Initial...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>还记得以前做asp时，设计access数据库：一边添加字段，一边打开一个notepad记录，然后在代码里把这些字段都加上。</p>
<p>现在可以使用SQL将表的所有列名显示，代码如下：</p>
<p>&nbsp;</p>
<blockquote>
<p>DECLARE @colName varchar(500) &#8211;声明@colName变量</p>
<p>DECLARE @tableName varchar(64)&#8211;声明表名</p>
<p>set @tableName=&#39;AppDog&#39;&#8211;赋表名</p>
<p>set @colName=&#39;&#39;&#8211;赋初值</p>
<p>SELECT @colName=@colName+COLUMN_NAME+&#39;,&#39; FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=@tableName</p>
<p>print subString(@colName,1,len(@colName)-1)&#8211;打印字段时去掉最后一个逗号</p>
</blockquote>
<p>运行</p>
<p><img alt="" height="309" src="http://www.51obj.cn/wp-content/uploads/SQL.png" width="546" /></p>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=547' rel='bookmark' title='Permanent Link: asp.net中恢复数据库的问题'>asp.net中恢复数据库的问题</a> <small>项目中使用到了恢复数据库的功能。直接使用RESTORE DATABASE table FROM DISK=&#39;Path&#39;;结果出现了不少问题。 尚未备份数据库的日志尾部 异常详细信息: System.Data.SqlClient.SqlException: 尚未备份数据库 &quot;HopeLoan2009&quot;...</small></li>
<li><a href='http://www.51obj.cn/?p=911' rel='bookmark' title='Permanent Link: SQL中以迪卡尔积插入数据'>SQL中以迪卡尔积插入数据</a> <small>很久没有写文章了，今天做项目时温习了一下SQL。现在有三张表S_action_info、E_grade_info、S_action_grade，其中第三张表为中间表，用于保存前两张表多对多关系。 数据结构图如下： 其它字段可不必考虑，重要的有前两张表的主键，和第三张表中相对应的外键。前两张表中已有部分数据，需要对第三张表进行一些测试数据的插入。于是SQL语句如下： ?View Code SQL/* *若建立存储过程 IF EXISTS(SELECT name...</small></li>
<li><a href='http://www.51obj.cn/?p=837' rel='bookmark' title='Permanent Link: 闲来没事发一个C#做的一个东西'>闲来没事发一个C#做的一个东西</a> <small>使用.net2.0开发，可查看系统服务信息、系统进程信息及软件安装信息，其中根据进程查看进程功能有待进一步完善；软件安装信息根据注册表信息来提取，由于有些软件图标无法获得，因此获得的软件列表并不完全。 源码完全开放，使用VS2005 SP1打开。 ?View Code CSHARP /// &lt;summary&gt; /// Initial...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=919</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>“集合已修改；可能无法执行枚举操作”</title>
		<link>http://www.51obj.cn/?p=917</link>
		<comments>http://www.51obj.cn/?p=917#comments</comments>
		<pubDate>Sun, 04 Jul 2010 02:37:45 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=917</guid>
		<description><![CDATA[对泛型进行比较移除时使用如下代码，出现运行错误：&#8220;集合已修改；可能无法执行枚举操 作&#8221;： 这种情况是由于System.Collection.Generic泛型中集合List&#60;&#62;中执行了Remove()方法，则原有... 


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>对泛型进行比较移除时使用如下代码，出现运行错误：&ldquo;<span style="color: rgb(204, 0, 51);">集合已修改</span><span style="color:<br />
rgb(0, 0, 204);">；</span><span style="color: rgb(204, 0, 51);">可能无法执行枚举操 作&rdquo;</span>：</p>
<p><img alt="" height="271" src="http://www.51obj.cn/wp-content/uploads/collectionError.png" width="406" /></p>
<p>这种情况是由于System.Collection.Generic泛型中集合List&lt;&gt;中执行了Remove()方法，则原有集合将被修改，而foreach的实现依赖于IEnumerable接口或实现GetEnumerator方法，这样均需要使用List&lt;&gt;实例的length属性。由于原有集合的长度为不确定因素，此时则将出现无法实现进行枚举操作的逻辑错误。</p>
<p>解决方法是使用for循环进行遍历删除，并将游标变量在删除元素的同时自减1.</p>
<p><img alt="" height="213" src="http://www.51obj.cn/wp-content/uploads/collectionErrorResolved.png" width="524" /></p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=917</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SQL中以迪卡尔积插入数据</title>
		<link>http://www.51obj.cn/?p=911</link>
		<comments>http://www.51obj.cn/?p=911#comments</comments>
		<pubDate>Fri, 02 Jul 2010 03:20:29 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=911</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
很久没有写文章了，今天做项目时温习了一下SQL。现在有三张表S_action_info、E_grade_info、S_action_grade，其中第三张表为中间表，用于保存前两张表多对多关系。 数据结构图如下： 其它字段可不必... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=547' rel='bookmark' title='Permanent Link: asp.net中恢复数据库的问题'>asp.net中恢复数据库的问题</a> <small>项目中使用到了恢复数据库的功能。直接使用RESTORE DATABASE table FROM DISK=&#39;Path&#39;;结果出现了不少问题。 尚未备份数据库的日志尾部 异常详细信息: System.Data.SqlClient.SqlException: 尚未备份数据库 &quot;HopeLoan2009&quot;...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>很久没有写文章了，今天做项目时温习了一下SQL。现在有三张表S_action_info、E_grade_info、S_action_grade，其中第三张表为中间表，用于保存前两张表多对多关系。</p>
<p>数据结构图如下：</p>
<p><img alt="" height="297" src="http://www.51obj.cn/wp-content/uploads/DataInsert.png" width="731" /></p>
<p>其它字段可不必考虑，重要的有前两张表的主键，和第三张表中相对应的外键。前两张表中已有部分数据，需要对第三张表进行一些测试数据的插入。于是SQL语句如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p911code13'); return false;">View Code</a> SQL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p91113"><td class="code" id="p911code13"><pre class="sql" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
 *若建立存储过程
IF EXISTS(SELECT name FROM sysobjects WHERE name=&amp;#39;InsertDataIntoS_action_grade&amp;#39; AND TYPE=&amp;#39;p&amp;#39;)
	DROP PROCEDURE InsertDataIntoS_action_grade
GO
CREATE PROCEDURE InsertDataIntoS_action_grade
	@actionCount int--1表数据记录总数
	@gradeCount int--2表数据记录总数	
	@actionIndex int--1表起始索引
	@gradeIndex int--2表起始索引
AS*/</span>
<span style="color: #808080; font-style: italic;">--TRUNCATE TABLE S_action_grade 如有必要，清空已有数据</span>
declare @actionCount int<span style="color: #808080; font-style: italic;">--1表数据记录总数</span>
declare @gradeCount int<span style="color: #808080; font-style: italic;">--2表数据记录总数</span>
declare @actionIndex int<span style="color: #808080; font-style: italic;">--1表起始索引</span>
declare @gradeIndex int<span style="color: #808080; font-style: italic;">--2表起始索引</span>
<span style="color: #993333; font-weight: bold;">set</span> @actionCount<span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">select</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">from</span> s_action_info<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">set</span> @gradeCount<span style="color: #66cc66;">=</span><span style="color: #66cc66;">&#40;</span><span style="color: #993333; font-weight: bold;">select</span> count<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">from</span> e_grade_info<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">set</span> @actionIndex<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>
while @actionIndex&amp;lt;<span style="color: #66cc66;">=</span>@actionCount
begin
	<span style="color: #993333; font-weight: bold;">set</span> @gradeIndex<span style="color: #66cc66;">=</span><span style="color: #cc66cc;">1</span>
	while @gradeIndex&amp;lt;<span style="color: #66cc66;">=</span>@gradeCount
		begin
			<span style="color: #993333; font-weight: bold;">insert</span> <span style="color: #993333; font-weight: bold;">into</span> s_action_grade<span style="color: #66cc66;">&#40;</span>action_id<span style="color: #66cc66;">,</span>grade_id<span style="color: #66cc66;">,</span>day_process_money<span style="color: #66cc66;">,</span>total_process_money<span style="color: #66cc66;">,</span>tip_type<span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">values</span><span style="color: #66cc66;">&#40;</span>@actionIndex<span style="color: #66cc66;">,</span>@gradeIndex<span style="color: #66cc66;">,</span><span style="color: #cc66cc;">100000</span><span style="color: #66cc66;">,</span><span style="color: #cc66cc;">10000000</span><span style="color: #66cc66;">,</span>&amp;#<span style="color: #cc66cc;">39</span>;<span style="color: #cc66cc;">1</span>&amp;#<span style="color: #cc66cc;">39</span>;<span style="color: #66cc66;">&#41;</span>
			<span style="color: #993333; font-weight: bold;">set</span> @gradeIndex<span style="color: #66cc66;">=</span>@gradeIndex<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span>
		end
	<span style="color: #993333; font-weight: bold;">set</span> @actionIndex<span style="color: #66cc66;">=</span>@actionIndex<span style="color: #66cc66;">+</span><span style="color: #cc66cc;">1</span>
end
go</pre></td></tr></table></div>

<p>执行后结果：</p>
<p><img alt="" height="396" src="http://www.51obj.cn/wp-content/uploads/InsertData.png" width="639" /></p>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=547' rel='bookmark' title='Permanent Link: asp.net中恢复数据库的问题'>asp.net中恢复数据库的问题</a> <small>项目中使用到了恢复数据库的功能。直接使用RESTORE DATABASE table FROM DISK=&#39;Path&#39;;结果出现了不少问题。 尚未备份数据库的日志尾部 异常详细信息: System.Data.SqlClient.SqlException: 尚未备份数据库 &quot;HopeLoan2009&quot;...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=911</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>.net framework移除工具，解决.net framework无法安装问题</title>
		<link>http://www.51obj.cn/?p=906</link>
		<comments>http://www.51obj.cn/?p=906#comments</comments>
		<pubDate>Mon, 31 May 2010 03:38:46 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[asp.net]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=906</guid>
		<description><![CDATA[由于.net framework 2.0卸载需要重装，但在重装过程中提示： setup cannot continue because this version of the .net framework is incompatible with a previously installed one&#160;http://support.microsoft.com/support/kb/articles/q312/5/00.a... 


No related posts.

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[<p>由于.net framework 2.0卸载需要重装，但在重装过程中提示：</p>
<p>setup cannot continue because this version of the .net framework is incompatible with a previously installed one&nbsp;http://support.microsoft.com/support/kb/articles/q312/5/00.asp </p>
<p>这是由于.net framework没有完整移除的原因，可下载使用.NET Framework Cleanup Tool，详细介绍在这里<a href="http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx" target="_blank">http://blogs.msdn.com/b/astebner/archive/2008/08/28/8904493.aspx</a> </p>
<p>可用于移除当前.net framework的所有版本，可选择单个移除，或者全部移除所有版本。</p>
<p><img alt="" height="238" src="http://www.51obj.cn/wp-content/uploads/net_framework_cleanup_tool.png" width="395" /></p>
<p>下载地址为：<a href="http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-08-90-44-93/dotnetfx_5F00_cleanup_5F00_tool.zip" target="_blank">http://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Components-PostAttachments/00-08-90-44-93/dotnetfx_5F00_cleanup_5F00_tool.zip</a></p>


<p>No related posts.</p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=906</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>关于拖动层效果</title>
		<link>http://www.51obj.cn/?p=896</link>
		<comments>http://www.51obj.cn/?p=896#comments</comments>
		<pubDate>Sat, 22 May 2010 13:58:29 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=896</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
在cnblogs上看到这篇文章http://www.cnblogs.com/idche/archive/2010/05/18/1738449.html；其中一段实现拖动div的代码相当精彩： ?View Code JSvar $=function(id){return document.getElementById(id);}; &#160; var getMouseP=function (e){//... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=531' rel='bookmark' title='Permanent Link: 关于previousSibling与nextSibling'>关于previousSibling与nextSibling</a> <small>firefox中会出现一个奇怪的现象，就是p1的previousSibling与nextSibling均返回undefined，使用nodeType测试 p1.previousSibling会返回3，也就是文本属性——firefox把p1与h4之间的回车换行也当作了一个元素！这种形式：（“\n ”） 因此在使用previousSibling与nextSibling时需要去做一些处理，一是可以将其节点之间的换行回车删除；二是使用p1.previousSibling.previousSibling这种间接方式来获取。...</small></li>
<li><a href='http://www.51obj.cn/?p=336' rel='bookmark' title='Permanent Link: js中的冒泡事件与事件监听'>js中的冒泡事件与事件监听</a> <small>js中“冒泡事件”并不是能实际使用的花哨技巧，它是一种对js事件执行顺序的机制，“冒泡算法”在编程里是一个经典问题，冒泡算法里面的冒泡应该说是交换更加准确；js里面的“冒泡事件”才是真正意义上的“冒泡”，它从DOM最低层逐层遍历树，然后附加相应事件。...</small></li>
<li><a href='http://www.51obj.cn/?p=604' rel='bookmark' title='Permanent Link: js中的链式调用'>js中的链式调用</a> <small>jQuery中形如$("#txtName").addClass("err").css("font-size","12px").select().focus();的方式让人不得不为之着迷。其实现机制就是链式调用。链式调用就是调用对象的方法后返回到该对象，严格来讲它并不属于语法，而只是一种语法技巧，js令人着迷的一点就是这里。...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>在cnblogs上看到这篇文章<a href="http://www.cnblogs.com/idche/archive/2010/05/18/1738449.html" target="_blank">http://www.cnblogs.com/idche/archive/2010/05/18/1738449.html</a>；其中一段实现拖动div的代码相当精彩：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p896code16'); return false;">View Code</a> JS</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p89616"><td class="code" id="p896code16"><pre class="js" style="font-family:monospace;">var $=function(id){return document.getElementById(id);};
&nbsp;
var getMouseP=function (e){//获取鼠标坐标 请传递evnet参数
&nbsp;
				e = e || window.event;
				var m=(e.pageX || e.pageY)?{ x:e.pageX, y:e.pageY } : { x:e.clientX + document.body.scrollLeft - document.body.clientLeft, y:e.clientY + document.body.scrollTop  - document.body.clientTop };
				   return m;
&nbsp;
			};
&nbsp;
move=function(o,t){
				o=$(o);
				t=$(t);
				o.onmousedown=function(ev){
					var mxy=getMouseP(ev);//获取当前鼠标坐标
					var by={x:mxy.x-(t.offsetLeft),y:mxy.y-(t.offsetTop)};
					o.style.cursor=&quot;move&quot;;
					document.onmousemove=function(ev){
							var mxy=getMouseP(ev);
							t.style.left=mxy.x-by.x+&quot;px&quot;;
							t.style.top=mxy.y-by.y+&quot;px&quot;;
						};
					document.onmouseup=function(){
							window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
							this.onmousemove=null;
						}
				}
	}
move(&quot;jelle_test_div&quot;,&quot;jelle_test_div&quot;);</pre></td></tr></table></div>

<p><a href="http://www.51obj.cn/demo/Drag.html" target="_blank">查看演示</a></p>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=531' rel='bookmark' title='Permanent Link: 关于previousSibling与nextSibling'>关于previousSibling与nextSibling</a> <small>firefox中会出现一个奇怪的现象，就是p1的previousSibling与nextSibling均返回undefined，使用nodeType测试 p1.previousSibling会返回3，也就是文本属性——firefox把p1与h4之间的回车换行也当作了一个元素！这种形式：（“\n ”） 因此在使用previousSibling与nextSibling时需要去做一些处理，一是可以将其节点之间的换行回车删除；二是使用p1.previousSibling.previousSibling这种间接方式来获取。...</small></li>
<li><a href='http://www.51obj.cn/?p=336' rel='bookmark' title='Permanent Link: js中的冒泡事件与事件监听'>js中的冒泡事件与事件监听</a> <small>js中“冒泡事件”并不是能实际使用的花哨技巧，它是一种对js事件执行顺序的机制，“冒泡算法”在编程里是一个经典问题，冒泡算法里面的冒泡应该说是交换更加准确；js里面的“冒泡事件”才是真正意义上的“冒泡”，它从DOM最低层逐层遍历树，然后附加相应事件。...</small></li>
<li><a href='http://www.51obj.cn/?p=604' rel='bookmark' title='Permanent Link: js中的链式调用'>js中的链式调用</a> <small>jQuery中形如$("#txtName").addClass("err").css("font-size","12px").select().focus();的方式让人不得不为之着迷。其实现机制就是链式调用。链式调用就是调用对象的方法后返回到该对象，严格来讲它并不属于语法，而只是一种语法技巧，js令人着迷的一点就是这里。...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=896</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C#数据结构三：单链表Singly Linked List</title>
		<link>http://www.51obj.cn/?p=889</link>
		<comments>http://www.51obj.cn/?p=889#comments</comments>
		<pubDate>Sat, 01 May 2010 02:26:39 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[数据结构]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=889</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
单链表 单链表（Singly Linked List），也称单向链表，链表中的一种，其特点链接方向是意向的，对链表的访问要通过顺序读取。在顺序链表中元素之间紧密相连，为了表示两个数据元素逻辑上的... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=825' rel='bookmark' title='Permanent Link: C#数据结构二：线性表'>C#数据结构二：线性表</a> <small>线性表定义 线性表Linear List：由n(n&gt;=0)个相同类型的数据元素构成的有限序列。记为L=(a1,a2,&#8230;,ai-1,ai,ai+1,&#8230;,an)。可使用下式表示： L=(D,R) 其中，D是数据元素的有限集合，R是数据元素之间关系的有限集合。 线性表基本操作包括插入操作、删除操作、查找、清空等。 线性表的接口类图如下： 接口代码如下： ?View Code...</small></li>
<li><a href='http://www.51obj.cn/?p=683' rel='bookmark' title='Permanent Link: C#难点逐个击破（10）：is与as'>C#难点逐个击破（10）：is与as</a> <small>is C#中允许数据在继承链中向下转型，在转换前需要判断数据的类型，可以使用is来判断基础类型。可以这样来理解：若该对象可以非空，且可以强制转换为所提供的类型而不引发异常，则is表达式返回true。使用语法为： if(obj is objType) { } 若obj为null则返回false； /// &lt;summary&gt;...</small></li>
<li><a href='http://www.51obj.cn/?p=730' rel='bookmark' title='Permanent Link: C#难点逐个击破（13）：异常与throw'>C#难点逐个击破（13）：异常与throw</a> <small>深层次详解Exception 在Ilustrustor C# 2008中这样描述Exception:The BCL defines a number of exception...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p><strong>单链表</strong></p>
<p>单链表（Singly Linked List），也称单向链表，链表中的一种，其特点链接方向是意向的，对链表的访问要通过顺序读取。在顺序链表中元素之间紧密相连，为了表示两个数据元素逻辑上的相邻关系，除了存储数据元素本身的信息外，还要存储与其相邻的下一数据元素的存储地址信息，也就是指针信息，也叫引用域。数据元素信息和指针信息组成该数据元素的存储映像，这就是节点（Node）。<br />
<img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042922113383.png" alt="" width="200" height="62" /><br />
数据域也可使用data表示，指针域使用next表示。</p>
<p>这样线性表就通过每个结点的指针域形成了一根“链条”，也就是我们所说的“链表”。如果结点的引用域只存储该节点直接后继节点的指针域，则该链表称为单链表（Singly Linked List)。单链表结构如下图（图片来自wikipedia）：</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042922145225.png" alt="" width="408" height="41" /></p>
<p>单链表：</p>
<p>1、末端节点的指针域为空，表示链表的结束；</p>
<p>2、元素间的物理关系是松散的；</p>
<p>3、每一节点存储实际数据，及下一节点的指针，来实现逻辑上的关联。</p>
<p>若末端节点的指针指向头节点，则此链表形成环状，称为单向循环链表（Circularly Linked List）；此时的终端节点也就失去了其意义。</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042922193828.png" alt="" width="350" height="60" /></p>
<p><strong>单链表实现</strong></p>
<p>1、节点定义：</p>
<p>节点类图如下</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042922353624.png" alt="" width="163" height="201" /></p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p889code34'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88934"><td class="code" id="p889code34"><pre class="csharp" style="font-family:monospace;"> <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
 <span style="color: #008080; font-style: italic;">/// 节点定义</span>
 <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
 <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> Node<span style="color: #008000;">&lt;</span>t<span style="color: #008000;">&gt;</span>
 <span style="color: #008000;">&#123;</span>
     <span style="color: #0600FF; font-weight: bold;">private</span> T data<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//数据域</span>
     <span style="color: #0600FF; font-weight: bold;">private</span> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> next<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//引用域</span>
     <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
     <span style="color: #008080; font-style: italic;">/// 构造器，数据值为输入数据值</span>
     <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
     <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;val&quot;&gt;&lt;/param&gt;</span>
     <span style="color: #0600FF; font-weight: bold;">public</span> Node<span style="color: #008000;">&#40;</span>T val<span style="color: #008000;">&#41;</span>
     <span style="color: #008000;">&#123;</span>
         data <span style="color: #008000;">=</span> val<span style="color: #008000;">;</span>
         next <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
     <span style="color: #008000;">&#125;</span>
     <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
     <span style="color: #008080; font-style: italic;">/// 构造器，数据值为系统默认值</span>
     <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
     <span style="color: #0600FF; font-weight: bold;">public</span> Node<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
     <span style="color: #008000;">&#123;</span>
         data <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
         next <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
     <span style="color: #008000;">&#125;</span>
     <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
     <span style="color: #008080; font-style: italic;">/// 数据域属性</span>
     <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
     <span style="color: #0600FF; font-weight: bold;">public</span> T Data
     <span style="color: #008000;">&#123;</span>
         get <span style="color: #008000;">&#123;</span><span style="color: #0600FF; font-weight: bold;">return</span> data<span style="color: #008000;">;</span><span style="color: #008000;">&#125;</span>
         set <span style="color: #008000;">&#123;</span> data <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
     <span style="color: #008000;">&#125;</span>
     <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
     <span style="color: #008080; font-style: italic;">/// 引用域属性</span>
     <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
     <span style="color: #0600FF; font-weight: bold;">public</span> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> Next
     <span style="color: #008000;">&#123;</span>
         get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> next<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
         set <span style="color: #008000;">&#123;</span> next <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
     <span style="color: #008000;">&#125;</span>
 <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p>2、单链表实现</p>
<p>单链表类图如下：</p>
<p>代码如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p889code35'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88935"><td class="code" id="p889code35"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// 单链表实现</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SinglyLinkedList<span style="color: #008000;">&lt;</span>t<span style="color: #008000;">&gt;:</span>IListDS<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> head<span style="color: #008000;">;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 单链表的头节点</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> Head
    <span style="color: #008000;">&#123;</span>
        get <span style="color: #008000;">&#123;</span> <span style="color: #0600FF; font-weight: bold;">return</span> head<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
        set <span style="color: #008000;">&#123;</span> head <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span> <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 构造器，构造具有空指针的头节点</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> SinglyLinkedList<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        head <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 求单链表长度</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> GetLength<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> currNode <span style="color: #008000;">=</span> head<span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> length <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>currNode <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008000;">++</span>length<span style="color: #008000;">;</span>
            currNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> length<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 清空单链表</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Clear<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        head <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 判断单链表是否为空</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">&#40;</span>head <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">?</span> <span style="color: #0600FF; font-weight: bold;">true</span> <span style="color: #008000;">:</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 在单链表末尾添加新元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;item&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Append<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> newNode <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> currNode <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>head <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            head <span style="color: #008000;">=</span> newNode<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        currNode <span style="color: #008000;">=</span> head<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            currNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">=</span> newNode<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 在指定位置插入元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;item&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;pos&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Insert<span style="color: #008000;">&#40;</span>T item, <span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> pos <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The list is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        Node<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> newNode <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>pos <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            newNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">=</span> head<span style="color: #008000;">;</span>
            head <span style="color: #008000;">=</span> newNode<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> currNode <span style="color: #008000;">=</span> head<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> preNode <span style="color: #008000;">=</span> head<span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> index <span style="color: #008000;">&lt;</span> pos<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            preNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">;</span>
            currNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">++</span>index<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>index <span style="color: #008000;">==</span> pos<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            newNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">=</span> currNode<span style="color: #008000;">;</span>
            preNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">=</span> newNode<span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position is error&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 删除指定索引位置的元素</span>
    <span style="color: #008080; font-style: italic;">/// </span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;pos&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> T Delete<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> pos <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The Link is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        T data <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>pos <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            data <span style="color: #008000;">=</span> head<span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span><span style="color: #008000;">;</span>
            head <span style="color: #008000;">=</span> head<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> data<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        Node<span style="color: #008000;">&lt;</span>T<span style="color: #008000;">&gt;</span> preNode <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">head</span><span style="color: #008000;">;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> currNode <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">head</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> index <span style="color: #008000;">&lt;</span> pos<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008000;">++</span>index<span style="color: #008000;">;</span>
            preNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">;</span>
            currNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>index <span style="color: #008000;">==</span> pos<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            preNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position is out of range&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 根据索引查找</span>
    <span style="color: #008080; font-style: italic;">/// </span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;pos&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> T GetElem<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The list is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> currNode <span style="color: #008000;">=</span> head<span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span> <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> index <span style="color: #008000;">&lt;</span> pos<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #008000;">++</span>index<span style="color: #008000;">;</span>
            currNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>index <span style="color: #008000;">==</span> pos<span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position is out of range&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 根据值查找</span>
    <span style="color: #008080; font-style: italic;">/// </span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;value&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Locate<span style="color: #008000;">&#40;</span>T value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The list is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span> currNode <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Node<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        currNode <span style="color: #008000;">=</span> head<span style="color: #008000;">;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> pos <span style="color: #008000;">=</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>currNode <span style="color: #008000;">!=</span> <span style="color: #0600FF; font-weight: bold;">null</span> <span style="color: #008000;">&amp;&amp;</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Data</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>value<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            currNode <span style="color: #008000;">=</span> currNode<span style="color: #008000;">.</span><span style="color: #0000FF;">Next</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">++</span>pos<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>currNode <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> pos<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p>调用演示：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p889code36'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p88936"><td class="code" id="p889code36"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// 功能：单链表演示</span>
<span style="color: #008080; font-style: italic;">/// 开发：walkingp</span>
<span style="color: #008080; font-style: italic;">/// 时间：2010-4-29</span>
<span style="color: #008080; font-style: italic;">/// 主页：http://www.51obj.cn/</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #6666cc; font-weight: bold;">class</span> Program
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        SinglyLinkedList<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span> demoList <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SinglyLinkedList<span style="color: #008000;">&lt;/</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;&lt;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #008080; font-style: italic;">/*添加*/</span>
        demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wang Hongjian&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;ZhangSan&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;LiSi&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The {0} item is:<span style="color: #008080; font-weight: bold;">\t</span>{1}&quot;</span>,i, demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElem</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #008080; font-style: italic;">/*插入*/</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Insert the item:&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Zhangyu&quot;</span>, <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The {0} item is:<span style="color: #008080; font-weight: bold;">\t</span>{1}&quot;</span>, i, demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElem</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #008080; font-style: italic;">/*删除*/</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Delelte the item:&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Delete</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">3</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> i <span style="color: #008000;">&lt;</span> demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span> i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The {0} item is:<span style="color: #008080; font-weight: bold;">\t</span>{1}&quot;</span>, i, demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElem</span><span style="color: #008000;">&#40;</span>i<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #008080; font-style: italic;">/*根据索引查找*/</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The 2st item is:<span style="color: #008080; font-weight: bold;">\t</span>{0}&quot;</span>, demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElem</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008080; font-style: italic;">/*根据值查找*/</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position of the item 'Wang Hongjian' is:<span style="color: #008080; font-weight: bold;">\t</span>{0}&quot;</span>,demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Locate</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Wang Hongjian&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008080; font-style: italic;">/*清空*/</span>
        demoList<span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Now the list is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>演示效果：</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042923272017.png" alt="" width="516" height="303" /></p>
<p><a href="http://files.cnblogs.com/walkingp/SinglyLinkedList.rar">源码下载</a></string></pre>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=825' rel='bookmark' title='Permanent Link: C#数据结构二：线性表'>C#数据结构二：线性表</a> <small>线性表定义 线性表Linear List：由n(n&gt;=0)个相同类型的数据元素构成的有限序列。记为L=(a1,a2,&#8230;,ai-1,ai,ai+1,&#8230;,an)。可使用下式表示： L=(D,R) 其中，D是数据元素的有限集合，R是数据元素之间关系的有限集合。 线性表基本操作包括插入操作、删除操作、查找、清空等。 线性表的接口类图如下： 接口代码如下： ?View Code...</small></li>
<li><a href='http://www.51obj.cn/?p=683' rel='bookmark' title='Permanent Link: C#难点逐个击破（10）：is与as'>C#难点逐个击破（10）：is与as</a> <small>is C#中允许数据在继承链中向下转型，在转换前需要判断数据的类型，可以使用is来判断基础类型。可以这样来理解：若该对象可以非空，且可以强制转换为所提供的类型而不引发异常，则is表达式返回true。使用语法为： if(obj is objType) { } 若obj为null则返回false； /// &lt;summary&gt;...</small></li>
<li><a href='http://www.51obj.cn/?p=730' rel='bookmark' title='Permanent Link: C#难点逐个击破（13）：异常与throw'>C#难点逐个击破（13）：异常与throw</a> <small>深层次详解Exception 在Ilustrustor C# 2008中这样描述Exception:The BCL defines a number of exception...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=889</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C#数据结构二：线性表</title>
		<link>http://www.51obj.cn/?p=825</link>
		<comments>http://www.51obj.cn/?p=825#comments</comments>
		<pubDate>Mon, 26 Apr 2010 15:03:49 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[数据结构]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=825</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
线性表定义 线性表Linear List：由n(n&#62;=0)个相同类型的数据元素构成的有限序列。记为L=(a1,a2,&#8230;,ai-1,ai,ai+1,&#8230;,an)。可使用下式表示： L=(D,R) 其中，D是数据元素的有限集合，R是数据元素之... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=683' rel='bookmark' title='Permanent Link: C#难点逐个击破（10）：is与as'>C#难点逐个击破（10）：is与as</a> <small>is C#中允许数据在继承链中向下转型，在转换前需要判断数据的类型，可以使用is来判断基础类型。可以这样来理解：若该对象可以非空，且可以强制转换为所提供的类型而不引发异常，则is表达式返回true。使用语法为： if(obj is objType) { } 若obj为null则返回false； /// &lt;summary&gt;...</small></li>
<li><a href='http://www.51obj.cn/?p=810' rel='bookmark' title='Permanent Link: C#难点逐个击破（20）：索引器indexer、枚举数Enumerator与迭代器Iterator'>C#难点逐个击破（20）：索引器indexer、枚举数Enumerator与迭代器Iterator</a> <small>索引器 我们知道，数组可以保存一系列具有相同数据类型的数据。在类或结构接口中，也可以像引用数组一样引用自己的成员，这就是索引器。索引器是具有索引参数的属性。 ?View Code CSHARPclass IndexerSample&lt;t&gt; &#123; public T&#91;&#93; arr...</small></li>
<li><a href='http://www.51obj.cn/?p=764' rel='bookmark' title='Permanent Link: C#难点逐个击破（16）：事件'>C#难点逐个击破（16）：事件</a> <small>在委托(delegate)里讲到每个委托都关联一系列成员，称为调用列表（invocation list）；一旦委托被调用，列表中的每一个成员也都会被调用，并获得委托所收到的参数。 在msdn中这样定义事件： 在发生其他类或对象关注的事情时，类或对象可通过事件通知它们。 举个例子，你在等一个人，于是每过10分钟都会下楼去看看那个人是不是已经到了，如果没有到就返回，10分钟后继续下楼；现在给一楼安装一个门铃，于是你不再需要频繁的下楼去检查，只要听到门铃的声音，然后下楼开门就可以了。 这个例子就是事件驱动模型，由于门铃的介入，现在变成了人对门铃声音的监听，这个门铃也就是消息。 事件有发送事件的类称为&ldquo;发行者&ldquo;，接收事件的类的称为&rdquo;订阅者&ldquo;。发行者与订阅者需要存在一个媒介， 这个媒介称为事件的处理方法。 C#中事件处理如下： 1、定义事件...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p><strong>线性表定义</strong></p>
<p>线性表Linear List：由n(n&gt;=0)个<strong>相同类型</strong>的数据元素构成的<strong>有限</strong>序列。记为L=(a<sub>1</sub>,a<sub>2</sub>,&#8230;,a<sub>i-1</sub>,a<sub>i</sub>,a<sub>i+1</sub>,&#8230;,a<sub>n</sub>)。可使用下式表示：</p>
<p>L=(D,R)</p>
<p>其中，D是数据元素的有限集合，R是数据元素之间关系的有限集合。</p>
<p>线性表基本操作包括插入操作、删除操作、查找、清空等。</p>
<p>线性表的接口类图如下：</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042523332013.png" alt="" width="166" height="229" /></p>
<p>接口代码如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p825code62'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p82562"><td class="code" id="p825code62"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// 线性表接口</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">interface</span> IListDS<span style="color: #008000;">&lt;</span>t<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #6666cc; font-weight: bold;">bool</span> Insert<span style="color: #008000;">&#40;</span>T item,<span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//插入元素</span>
    <span style="color: #6666cc; font-weight: bold;">bool</span> IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//是否为空</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> GetLength<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//得到容量</span>
    <span style="color: #6666cc; font-weight: bold;">void</span> Append<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//添加新元素</span>
    <span style="color: #6666cc; font-weight: bold;">void</span> Clear<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//清空</span>
    T Delete<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//删除元素</span>
    T GetElem<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//根据索引查找</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> Locate<span style="color: #008000;">&#40;</span>T value<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//根据值查找</span>
<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p>线性表的分类</p>
<p>按线性表的元素结构分，可将线性表分为：</p>
<p>1、顺序表：将线性表中的结点按逻辑顺序依次存放在一组地址的存储单元中；</p>
<p>2、链表</p>
<p>1）单向链表：链表的链接方向是意向，对链表的访问要通过顺序读取从头部开始；</p>
<p>2）双向链表：其每个数据结点中都有两个指针，分别指向直接后继和直接前驱。</p>
<p>3）循环链接：其最后一个结点指向头结点，形成一个环；从循环链表中的任何一个结点出发都能找到任何其他结点。</p>
<p><strong>顺序表 </strong></p>
<p>顺序表（Sequence List）是在计算机内在中以数组的形式保存的线性表，是指用一组地址连续的存储单元依次存储数据元素的线性结构。</p>
<p>顺序表定义如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p825code63'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p82563"><td class="code" id="p825code63"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// 顺序表定义</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span>
<span style="color: #6666cc; font-weight: bold;">class</span> SeqListDef<span style="color: #008000;">&lt;</span>t<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
    T<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> datas<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//存放元素数组</span>
    <span style="color: #6666cc; font-weight: bold;">int</span> pointer<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//索引</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 构造器</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;maxSize&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> SeqListDef<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> maxSize<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        datas<span style="color: #008000;">=</span><a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> T<span style="color: #008000;">&#91;</span>maxSize<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 增加</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;item&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> AddItem<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        datas<span style="color: #008000;">&#91;</span><span style="color: #008000;">++</span>pointer<span style="color: #008000;">&#93;</span><span style="color: #008000;">=</span>item<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 显示元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> DisplayItems<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> j <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>, l <span style="color: #008000;">=</span> datas<span style="color: #008000;">.</span><span style="color: #0000FF;">Length</span><span style="color: #008000;">;</span> j <span style="color: #008000;">&lt;</span> l<span style="color: #008000;">;</span> j<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;datas[{0}]&quot;</span>, j<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>顺序表实现类图如下</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042621242010.png" alt="" width="166" height="420" /></p>
<p>其中GetElem是根据索引来查询，Locate是根据值来查询。</p>
<p>代码如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p825code64'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p82564"><td class="code" id="p825code64"><pre class="csharp" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// 顺序表</span>
<span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
<span style="color: #008080; font-style: italic;">/// &lt;typeparam name=&quot;T&quot;&gt;&lt;/typeparam&gt;</span>
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">class</span> SeqList<span style="color: #008000;">&lt;</span>t<span style="color: #008000;">&gt;:</span>IListDS<span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;&lt;</span>t<span style="color: #008000;">&gt;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #008080;">#region 变量成员</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> maxsize<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//容量</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> T<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> datas<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//存放元素的数组</span>
    <span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">int</span> last<span style="color: #008000;">;</span><span style="color: #008080; font-style: italic;">//末位置</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080;">#region 属性</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 最后一个元素位置</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Last
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> last<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 容量</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> MaxSize
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> maxsize<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            maxsize <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 索引器</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;index&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> T <span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">&#91;</span><span style="color: #6666cc; font-weight: bold;">int</span> index<span style="color: #008000;">&#93;</span>
    <span style="color: #008000;">&#123;</span>
        get
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> datas<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        set
        <span style="color: #008000;">&#123;</span>
            datas<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> value<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 构造器</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;size&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> SeqList<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> size<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        datas <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> T<span style="color: #008000;">&#91;</span>size<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        maxsize <span style="color: #008000;">=</span> size<span style="color: #008000;">;</span>
        last <span style="color: #008000;">=</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080;">#region 方法成员</span>
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 得到顺序表长度</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> GetLength<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> last <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 清空顺序表</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Clear<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        last <span style="color: #008000;">=</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 判断是否为空</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>last<span style="color: #008000;">==-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 判断顺序表是否已满</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> IsFull<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>last <span style="color: #008000;">==</span> maxsize <span style="color: #008000;">-</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 添加新元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;item&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">void</span> Append<span style="color: #008000;">&#40;</span>T item<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsFull<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The List's already full yet&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
&nbsp;
        datas<span style="color: #008000;">&#91;</span><span style="color: #008000;">++</span>last<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> item<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 插入元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;item&quot;&gt;元素&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;pos&quot;&gt;位置&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;是否插入成功&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">bool</span> Insert<span style="color: #008000;">&#40;</span>T item, <span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsFull<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The List's already full yet&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>pos<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span><span style="color: #FF0000;">0</span> <span style="color: #008000;">||</span> pos<span style="color: #008000;">&gt;</span>last<span style="color: #008000;">+</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position is error&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>pos <span style="color: #008000;">==</span> last <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span>
            datas<span style="color: #008000;">&#91;</span>pos<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> item<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> last<span style="color: #008000;">;</span> index <span style="color: #008000;">&gt;=</span> pos<span style="color: #008000;">;</span> <span style="color: #008000;">--</span>index<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                datas<span style="color: #008000;">&#91;</span>index <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> datas<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
            datas<span style="color: #008000;">&#91;</span>pos<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> item<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">++</span>last<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 删除元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;pos&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> T Delete<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        T tmp <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The List is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> tmp<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>pos<span style="color: #008000;">&amp;</span>lt<span style="color: #008000;">;</span><span style="color: #FF0000;">0</span> <span style="color: #008000;">||</span> pos<span style="color: #008000;">&gt;</span>last<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position is err&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> tmp<span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>pos <span style="color: #008000;">==</span> last<span style="color: #008000;">&#41;</span>
            tmp <span style="color: #008000;">=</span> datas<span style="color: #008000;">&#91;</span>last<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">else</span>
        <span style="color: #008000;">&#123;</span>
            tmp <span style="color: #008000;">=</span> datas<span style="color: #008000;">&#91;</span>pos<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> pos<span style="color: #008000;">;</span> index <span style="color: #008000;">&lt;</span> last<span style="color: #008000;">;</span> <span style="color: #008000;">++</span>index<span style="color: #008000;">&#41;</span>
            <span style="color: #008000;">&#123;</span>
                datas<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span> <span style="color: #008000;">=</span> datas<span style="color: #008000;">&#91;</span>index <span style="color: #008000;">+</span> <span style="color: #FF0000;">1</span><span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
            <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #008000;">--</span>last<span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> tmp<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 根据索引查找某一元素</span>
    <span style="color: #008080; font-style: italic;">/// </span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;pos&quot;&gt;索引&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> T GetElem<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> pos<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> <span style="color: #008000;">&#40;</span>pos <span style="color: #008000;">&lt;</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">||</span> pos <span style="color: #008000;">&gt;</span> last<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;List is empty or the position is error&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #0600FF; font-weight: bold;">default</span><span style="color: #008000;">&#40;</span>T<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">return</span> datas<span style="color: #008000;">&#91;</span>pos<span style="color: #008000;">&#93;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
&nbsp;
    <span style="color: #008080; font-style: italic;">/// &lt;summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// 根据值查找某一元素</span>
    <span style="color: #008080; font-style: italic;">/// &lt;/summary&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;param name=&quot;value&quot;&gt;&lt;/param&gt;</span>
    <span style="color: #008080; font-style: italic;">/// &lt;returns&gt;&lt;/returns&gt;</span>
    <span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #6666cc; font-weight: bold;">int</span> Locate<span style="color: #008000;">&#40;</span>T value<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>IsEmpty<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;List is empty&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #6666cc; font-weight: bold;">int</span> index <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
        <span style="color: #0600FF; font-weight: bold;">for</span> <span style="color: #008000;">&#40;</span>index <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span> index <span style="color: #008000;">&lt;</span> <span style="color: #008000;">=</span> last<span style="color: #008000;">;</span> <span style="color: #008000;">++</span>index<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>value<span style="color: #008000;">.</span><span style="color: #0000FF;">Equals</span><span style="color: #008000;">&#40;</span>datas<span style="color: #008000;">&#91;</span>index<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
                <span style="color: #0600FF; font-weight: bold;">break</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
        <span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span>index <span style="color: #008000;">&gt;</span> last<span style="color: #008000;">&#41;</span>
            <span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span><span style="color: #008000;">;</span>
&nbsp;
        <span style="color: #0600FF; font-weight: bold;">return</span> index<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    <span style="color: #008080;">#endregion</span>
<span style="color: #008000;">&#125;</span><span style="color: #008000;">&lt;/</span>t<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p>实例化调用：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p825code65'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p82565"><td class="code" id="p825code65"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> Main<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> args<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    SeqList<span style="color: #008000;">&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span> seqList <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> SeqList<span style="color: #008000;">&lt;/</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;&lt;</span><span style="color: #6666cc; font-weight: bold;">int</span><span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">8</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">21</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">22</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Append</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">23</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Inital the sequence list&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">for</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>i<span style="color: #008000;">&lt;</span>seqlist <span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>seqList<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Insert method sample:&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">20</span>, <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Insert</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">24</span>, <span style="color: #FF0000;">4</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">for</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>i<span style="color: #008000;">&lt;</span>seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>seqList<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Delete method sample:&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Delete</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #0600FF; font-weight: bold;">for</span><span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">int</span> i<span style="color: #008000;">=</span><span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>i<span style="color: #008000;">&lt;</span>seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>i<span style="color: #008000;">++</span><span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
        Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>seqList<span style="color: #008000;">&#91;</span>i<span style="color: #008000;">&#93;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The 2st item is:{0}&quot;</span>, seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetElem</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">1</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The position of value 23 is:{0}&quot;</span>, seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Locate</span><span style="color: #008000;">&#40;</span><span style="color: #FF0000;">23</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Empty the sequence list&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">Clear</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
    Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;The length of the sequence list is {0}&quot;</span>,seqList<span style="color: #008000;">.</span><span style="color: #0000FF;">GetLength</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>运行结果：</p>
<p><img class="alignnone" src="http://pic002.cnblogs.com/img/walkingp/201004/2010042621335482.png" alt="" width="444" height="367" /></p>
<p><a href="http://files.cnblogs.com/walkingp/SequenceList.rar">源码下载</a></seqlist></int></pre>
<p></t></pre>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=683' rel='bookmark' title='Permanent Link: C#难点逐个击破（10）：is与as'>C#难点逐个击破（10）：is与as</a> <small>is C#中允许数据在继承链中向下转型，在转换前需要判断数据的类型，可以使用is来判断基础类型。可以这样来理解：若该对象可以非空，且可以强制转换为所提供的类型而不引发异常，则is表达式返回true。使用语法为： if(obj is objType) { } 若obj为null则返回false； /// &lt;summary&gt;...</small></li>
<li><a href='http://www.51obj.cn/?p=810' rel='bookmark' title='Permanent Link: C#难点逐个击破（20）：索引器indexer、枚举数Enumerator与迭代器Iterator'>C#难点逐个击破（20）：索引器indexer、枚举数Enumerator与迭代器Iterator</a> <small>索引器 我们知道，数组可以保存一系列具有相同数据类型的数据。在类或结构接口中，也可以像引用数组一样引用自己的成员，这就是索引器。索引器是具有索引参数的属性。 ?View Code CSHARPclass IndexerSample&lt;t&gt; &#123; public T&#91;&#93; arr...</small></li>
<li><a href='http://www.51obj.cn/?p=764' rel='bookmark' title='Permanent Link: C#难点逐个击破（16）：事件'>C#难点逐个击破（16）：事件</a> <small>在委托(delegate)里讲到每个委托都关联一系列成员，称为调用列表（invocation list）；一旦委托被调用，列表中的每一个成员也都会被调用，并获得委托所收到的参数。 在msdn中这样定义事件： 在发生其他类或对象关注的事情时，类或对象可通过事件通知它们。 举个例子，你在等一个人，于是每过10分钟都会下楼去看看那个人是不是已经到了，如果没有到就返回，10分钟后继续下楼；现在给一楼安装一个门铃，于是你不再需要频繁的下楼去检查，只要听到门铃的声音，然后下楼开门就可以了。 这个例子就是事件驱动模型，由于门铃的介入，现在变成了人对门铃声音的监听，这个门铃也就是消息。 事件有发送事件的类称为&ldquo;发行者&ldquo;，接收事件的类的称为&rdquo;订阅者&ldquo;。发行者与订阅者需要存在一个媒介， 这个媒介称为事件的处理方法。 C#中事件处理如下： 1、定义事件...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=825</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>（译）在非IE浏览器中实现“灰阶化”</title>
		<link>http://www.51obj.cn/?p=860</link>
		<comments>http://www.51obj.cn/?p=860#comments</comments>
		<pubDate>Sat, 24 Apr 2010 03:48:03 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[翻译]]></category>
		<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=860</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
原文：&#8220;GRAYSCALING&#8221; IN NON-IE BROWSERS 原文作者：JAMES PADOLSEY 在非IE浏览器中实现&#8220;灰阶化[1]&#8221; 这个问题看似简单，实际上要付出很大的努力[2]。要的结果很简单：在所有非IE浏览器中... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=896' rel='bookmark' title='Permanent Link: 关于拖动层效果'>关于拖动层效果</a> <small>在cnblogs上看到这篇文章http://www.cnblogs.com/idche/archive/2010/05/18/1738449.html；其中一段实现拖动div的代码相当精彩： ?View Code JSvar $=function(id){return document.getElementById(id);}; &nbsp; var getMouseP=function (e){//获取鼠标坐标...</small></li>
<li><a href='http://www.51obj.cn/?p=380' rel='bookmark' title='Permanent Link: Jquery学习笔记（一）'>Jquery学习笔记（一）</a> <small>题外话：从今天起正式学习Jquery（实际严格讲已经用了几个月的Jquery的一丁点东西），边学边做边记笔记；阅读书籍《锋利的Jquery》+Jquery API Doc。 基础知识： 想要结构与行为分离当然不能使用&lt;button onclick=&quot;&#8230;&quot;&gt;&lt;/button&gt;之类的东西了，js是写在&lt;head&gt;之间的，那就说起了window.onload&mdash;&mdash;这不是一个好东西，所以就有了Jquery颇具创意的 $(document).ready(funciton(){ &#8230; }); 当然还会更精简：...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p><span style="color:#696969;">原文：<a href="http://james.padolsey.com/javascript/grayscaling-in-non-ie-browsers/" target="_blank">&ldquo;GRAYSCALING&rdquo; IN NON-IE BROWSERS<br />
	</a></span></p>
<p><span style="color:#696969;">原文作者：JAMES PADOLSEY</span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; font-weight: bold; line-height: 21px; ">在非IE浏览器中实现&ldquo;灰阶化<strong><sup>[1]</sup></strong>&rdquo;</span></p>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; ">这个问题看似简单，实际上要付出很大的努力<sup>[2]</sup>。要的结果很简单：在所有非IE浏览器中模拟Internet Explorer浏览器的grayscale（灰度）滤镜。然而，它的解决方法并非你想得那么简单，这也让我着实大大地吃了一惊。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">在IE中，<a href="http://msdn.microsoft.com/en-us/library/ms532889(VS.85).aspx" style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; text-decoration: none; color: rgb(0, 66, 118); " target="_blank">grayscale滤镜</a>可以应用到任意一个元素中，它会很直观地将元素转变为灰度。可以使用下面这行复杂且专有的CSS来实现grayscale滤镜。</span></p>
<blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; "><font class="Apple-style-span" color="#000000" face="Tahoma, Helvetica, Arial, sans-serif"><span class="Apple-style-span" style="line-height: 21px;">elem{&nbsp;<br />
		&nbsp;&nbsp; &nbsp; filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);&nbsp;<br />
		&nbsp;&nbsp; &nbsp; /* 元素必须有&ldquo;布局值&rdquo;! */<br />
		&nbsp;&nbsp; &nbsp; zoom: 1;&nbsp;<br />
		} &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</span></font></p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">如上所示，在IE中实现这种效果简单是小菜一碟；然而，在其他的浏览器中，需要引起很大的关注。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">需要有两件情况值得考虑：图片元素和非图片元素。&ldquo;非图片&rdquo;类元素实现十分简单：在当前文档中遍历每个元素，寻找类似&ldquo;backgroundColor&rdquo;和&ldquo;color&rdquo;的色彩属性，将它的RGB颜色值转换为灰度值。有不少方法可以实现；注意我们这里不是说降低图片的饱和度；&ldquo;灰阶化&rdquo;很明显跟它不一样。</span></p>
<blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; ">// 降低饱和度:<br />
		function RGBtoDesat(r,g,b) {<br />
		&nbsp;&nbsp; &nbsp;var average = (r + g + b) / 3;<br />
		&nbsp;&nbsp; &nbsp;return {<br />
		&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r: average,<br />
		&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g: average,<br />
		&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b: average<br />
		&nbsp;&nbsp; &nbsp; };<br />
		}</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; ">// 灰阶化:<br />
		function RGBtoGrayscale(r,g,b) {<br />
		&nbsp;&nbsp; &nbsp; var mono = parseInt( (0.2125 * r) + (0.7154 * g) + (0.0721 * b), 10 );&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;<br />
		&nbsp;&nbsp; &nbsp;return {&nbsp;<br />
		&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; r: mono,<br />
		&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; g: mono,<br />
		&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; b: mono<br />
		&nbsp;&nbsp; &nbsp; };<br />
		}</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; ">因此，每个带颜色属性的元素要使用它来转为灰阶；初始颜色用来重置属性值。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">我们的图片能否转为灰阶取决于两个因素；一是浏览器必须要支持HTML5 canvas元素和它getImageData方法，二是主机上的所有图片必须位于同一域名下；除此外，主机上的图片不能脱离getImageData方法而不管它是否支持<sup>[3]</sup>。Google Chrome浏览器和Safari（4以下版本）由于不支持getImageData，先不作讨论。其他的浏览器支持canvas元素，完全可以做到&ldquo;灰阶化&rdquo;图片。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">实现这种方式是要&ldquo;手工&rdquo;遍历图片中的每一像素，并应用我们用来设置CSS 颜色属性的RGBtoGrayscale函数。真要这样做的话，浏览器绝对吃不消；除非有极其快速的Javascript引擎来承受大图片处理的压力。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">鉴于上面提到的原因，因此在任一个元素需要&ldquo;灰阶化&rdquo;前，添加一个&ldquo;预置&rdquo;函数去运行显得尤为必要，这个函数可以使用零超时递归技术<sup>[4]</sup>来避免耗死浏览器。如果仅仅是小图片需要转换的话，不必使用&ldquo;预置&rdquo;函数，可以直接使用这种暴力转换。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; "><b style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">为什么呢，这是为什么呢？</b></span></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">你肯定想知道在&ldquo;灰阶化&rdquo;会有哪些应用。那么，比如说：降低色彩以减少用户的视觉焦点，以此来减少用户对你网站上五颜六色东西的关注；比如说，光箱特效。像vBulletin的论坛系统就使用了这种效果，它会你点击离开时，将页面变灰；然后会弹出确认框，这个确认框非很容易识别，因为它是页面中惟一的带色彩的东西。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">&ldquo;灰阶化&rdquo;困扰我的真实原因是因为我很想知道是否有可能做到这个目的。我已经知道在IE浏览器里有这个滤镜，我还想看看在其他浏览器中能否模拟实现这种方便的特效。我也知道这种特效可能被认为已经过时了，但这并不重要；我仅仅是对实现它很感兴趣。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; "><b style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">示例</b></span></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; ">我做了一个示例页面，上面有几个格斗士<sup>[5]</sup>的图片，功能已经在这篇文章中说过了。注意，在Safari（小于4）或者Chrome（还有可能在Firefox老版本（V.2以前））不起作用；不要忘了它仅仅是一个试验。</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><a href="http://james.padolsey.com/demos/grayscale/" target="_blank">查看演示</a></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; "><img alt="" height="391" src="http://www.51obj.cn/wp-content/uploads/robotscompare_grayscale.png" width="500" /><br />
	</span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; ">&nbsp;</p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; "><span class="Apple-style-span" style="line-height: 21px; "><span style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 18px; "><b style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">使用方法</b></span></span></span></p>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; font-size: 14px; line-height: 1.8; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; line-height: 21px; font-size: 14px; "><span class="Apple-style-span" style="line-height: 21px; ">要对一个元素实现&ldquo;灰阶化&rdquo;需要调用grayscale()函数，并将元素作为参数传递，比如：</span></span></p>
<blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; "><span style="font-size:12px;">var el = document.getElementById( &#39;myEl&#39; );<br />
		grayscale( el );&nbsp;<br />
		// 也可以传递一个DOM集合<br />
		// (这样所有的元素都会得到&ldquo;灰度效果&rdquo;)<br />
		grayscale( document.getElementsByTagName(&#39;div&#39;) );<br />
		&nbsp;//也可以在jQuery对象集合中使用<br />
		grayscale( $(&#39;div&#39;) );</span></p>
</blockquote>
<p><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; ">若要重置元素（返回到原来的颜色状态）必须调用grayscale.reset()，并将需要重置的元素作为参数传递：</span></p>
<blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; ">grayscale.reset( el );<br />
		// reset()同样可以接受DOM对象或jQuery对象集合参数<br />
		grayscale.reset( $(&#39;div&#39;) );</p>
</blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; "><span class="Apple-style-span" style="color: rgb(0, 0, 0); font-family: Tahoma, Helvetica, Arial, sans-serif; font-size: 14px; line-height: 21px; ">其中的prepare函数，上面已经讲过了，在有大图片要处理的情况下需要使用到，或者即使只是几个小图片。注意大图片需要有一会儿的时间去处理（一张300&times;300的PNG格式图片在&ldquo;预置&rdquo;方式下需要耗费3秒钟的时间）。</span></p>
<blockquote>
<p style="margin-top: 0px; margin-right: 0px; margin-bottom: 10px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; clear: both; ">grayscale.prepare( document.getElementById(&#39;myEl&#39;) );<br />
		// 同样可以接受DOM对象或jQuery对象集合参数<br />
		grayscale.prepare( $(&#39;.gall_img&#39;) );</p>
</blockquote>
<p><span class="Apple-style-span" style="font-size: 16px; ">[完]</span></p>
<p>注：</p>
<p>[1]:灰阶化：原文grayscaling，意为&ldquo;采取灰度标准&rdquo;，即灰阶化，将图片由彩色转为灰度；</p>
<p>[2]原文为&rdquo;This started out as a little experiment and eventually turned into quite an endeavor.&ldquo;，可能存在翻译问题；</p>
<p>[3]原文为&ldquo;externally hosted images cannot be passed into &lsquo;getImageData&rsquo; regardless of whether it&rsquo;s supported.&rdquo;，翻译存疑；</p>
<p>[4]零超时递归技术：原文zero-timeout recursion technique，应为zero-time recursive technique；参见<a href="http://en.wikipedia.org/wiki/Recursion_(computer_science)" target="_blank">http://en.wikipedia.org/wiki/Recursion_(computer_science)</a>；</p>
<p>[5]格斗士：原文blood-thirsty hunters，嗜血的猎人</p>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=896' rel='bookmark' title='Permanent Link: 关于拖动层效果'>关于拖动层效果</a> <small>在cnblogs上看到这篇文章http://www.cnblogs.com/idche/archive/2010/05/18/1738449.html；其中一段实现拖动div的代码相当精彩： ?View Code JSvar $=function(id){return document.getElementById(id);}; &nbsp; var getMouseP=function (e){//获取鼠标坐标...</small></li>
<li><a href='http://www.51obj.cn/?p=380' rel='bookmark' title='Permanent Link: Jquery学习笔记（一）'>Jquery学习笔记（一）</a> <small>题外话：从今天起正式学习Jquery（实际严格讲已经用了几个月的Jquery的一丁点东西），边学边做边记笔记；阅读书籍《锋利的Jquery》+Jquery API Doc。 基础知识： 想要结构与行为分离当然不能使用&lt;button onclick=&quot;&#8230;&quot;&gt;&lt;/button&gt;之类的东西了，js是写在&lt;head&gt;之间的，那就说起了window.onload&mdash;&mdash;这不是一个好东西，所以就有了Jquery颇具创意的 $(document).ready(funciton(){ &#8230; }); 当然还会更精简：...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=860</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS实现页面宽高100%自适应</title>
		<link>http://www.51obj.cn/?p=848</link>
		<comments>http://www.51obj.cn/?p=848#comments</comments>
		<pubDate>Sun, 18 Apr 2010 13:38:50 +0000</pubDate>
		<dc:creator>walkingp</dc:creator>
				<category><![CDATA[css]]></category>

		<guid isPermaLink="false">http://www.51obj.cn/?p=848</guid>
		<description><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->

<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
是做B/S的吧，网站或者MIS，后台一定做过，一般是上左右结构。 最常见的方法是使用frameset ?View Code XML&#60;frameset rows=&#34;78,*,31&#34; cols=&#34;*&#34; frameborder=&#34;no&#34; border=&#34;0&#34; framespacing=&#34;0&#... 


Related posts:<ol><li><a href='http://www.51obj.cn/?p=637' rel='bookmark' title='Permanent Link: js中鼠标滚轮事件详解'>js中鼠标滚轮事件详解</a> <small>?View Code JAVASCRIPT/*Firefox注册事件*/ if&#40;document.addEventListener&#41;&#123; document.addEventListener&#40;'DOMMouseScroll',scrollFunc,false&#41;; &#125; Safari与Chrome属于同一类型，可使用HTML DOM方式添加事件 ?View Code...</small></li>
<li><a href='http://www.51obj.cn/?p=368' rel='bookmark' title='Permanent Link: 如何检查浏览器类型'>如何检查浏览器类型</a> <small>使用检查navigator.userAgent字符串来判断浏览器类型。今天在看一篇文章中提到用户在某些浏览器可以更改userAgent，这样就不能单纯使用这个方法来检查浏览器。在实际使用中一般检查最多的是ie浏览器与标准dom浏览器的区别，这样可以使用window.addEventListener来判断这两种类型的浏览器...</small></li>
</ol>

以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。]]></description>
			<content:encoded><![CDATA[
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
<p>是做B/S的吧，网站或者MIS，后台一定做过，一般是上左右结构。</p>
<p><img alt="" height="338" src="http://www.51obj.cn/wp-content/uploads/full_screen_layout.png" width="450" /></p>
<p>最常见的方法是使用frameset</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p848code86'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84886"><td class="code" id="p848code86"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frameset</span> <span style="color: #000066;">rows</span>=<span style="color: #ff0000;">&quot;78,*,31&quot;</span> <span style="color: #000066;">cols</span>=<span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #000066;">frameborder</span>=<span style="color: #ff0000;">&quot;no&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">framespacing</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frame</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;top.aspx&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;topFrame&quot;</span> <span style="color: #000066;">scrolling</span>=<span style="color: #ff0000;">&quot;No&quot;</span> <span style="color: #000066;">noresize</span>=<span style="color: #ff0000;">&quot;noresize&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;topFrame&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frameset<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;frameset</span> <span style="color: #000066;">cols</span>=<span style="color: #ff0000;">&quot;170,*&quot;</span> <span style="color: #000066;">frameborder</span>=<span style="color: #ff0000;">&quot;no&quot;</span> <span style="color: #000066;">border</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">framespacing</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frame</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;left.aspx&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;leftFrame&quot;</span> <span style="color: #000066;">scrolling</span>=<span style="color: #ff0000;">&quot;No&quot;</span> <span style="color: #000066;">noresize</span>=<span style="color: #ff0000;">&quot;noresize&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;leftFrame&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frame</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;main.aspx&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;mainFrame&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;mainFrame&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/frameset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;frame</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;bottom.aspx&quot;</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;bottomFrame&quot;</span> <span style="color: #000066;">scrolling</span>=<span style="color: #ff0000;">&quot;No&quot;</span> <span style="color: #000066;">noresize</span>=<span style="color: #ff0000;">&quot;noresize&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;bottomFrame&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></td></tr></table></div>

<p>但框架在xhtml中并不推荐使用，完美一点当然还要使用div来实现，很早之前我就想过这个问题，但由于css并不容易实现这种效果，后来我使用div+css+js，尤其使用了js来控制页面中标签位置来实现，然而DOM在各浏览器中实现也不规范，所以这种方法也显得十分笨拙。</p>
<p>今天在blueidea中看到<a href="http://bbs.blueidea.com/viewthread.php?tid=2967753" target="_blank">这个帖子</a>，里面的解决方法令我恍然大悟。三个div全部使用绝对定位，其中header指定高度，对left指定宽度，然后right的left属性设置为left的宽度值。再使用CSS hack对ie6等进行兼容操作，便可达到结果。原帖中的答案存在一些问题。我修正后的结果如下：</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p848code87'); return false;">View Code</a> XML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p84887"><td class="code" id="p848code87"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #808080; font-style: italic;">&lt;!--</span>
<span style="color: #808080; font-style: italic;">html,body { height:100%; overflow:hidden;}</span>
<span style="color: #808080; font-style: italic;">body{margin:0;padding:0;}</span>
<span style="color: #808080; font-style: italic;">#header{position:absolute;top:0;width:100%;height:100px;background-color:#D6E6B7;}</span>
<span style="color: #808080; font-style: italic;">#left{position:absolute;top:100px;right:auto;left:0;bottom:0;width:200px;overflow:scroll;_height:100%;background-color:#D3EEEE;}</span>
<span style="color: #808080; font-style: italic;">#middle{position:absolute;top:100px;right:auto;left:200px; bottom:0;width:100%;overflow:scroll;_height:100%;background-color:#F0E1D3;}</span>
<span style="color: #808080; font-style: italic;">--&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/style<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;header&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;left&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>经过测试，兼容ie6及以上、opera、firefox、chrome、safari。其中的_height属性是为了兼容ie6。</p>
<p>其中的opera存在一个小小的bug，窗体大小改变时相应的div位置仍然保持上一次的位置。窗体大小改变前，div正常：</p>
<p><img alt="" height="342" src="http://www.51obj.cn/wp-content/uploads/full_screen_demo_opera_unresize.png" width="419" /></p>
<p>最大化当前页面时，会出现left仍然保持上一位置：</p>
<p><img alt="" height="485" src="http://www.51obj.cn/wp-content/uploads/full_screen_demo_opera_resize.png" width="523" /></p>
<p>同样在最大化转为普通窗体也会出现窗体整体出现滚动条的情况。</p>
<p>如果在left和middle都加height:100%，那么opera会出现当前窗体多出header部分的高度的情况。</p>
<p>那这样的话，如果实在要考虑opera的话，加上js吧。</p>
<p>备注一下，我的opera版本是10.10。见下图。</p>
<p><img alt="" height="229" src="http://www.51obj.cn/wp-content/uploads/opera_version.png" width="351" /></p>


<p>Related posts:<ol><li><a href='http://www.51obj.cn/?p=637' rel='bookmark' title='Permanent Link: js中鼠标滚轮事件详解'>js中鼠标滚轮事件详解</a> <small>?View Code JAVASCRIPT/*Firefox注册事件*/ if&#40;document.addEventListener&#41;&#123; document.addEventListener&#40;'DOMMouseScroll',scrollFunc,false&#41;; &#125; Safari与Chrome属于同一类型，可使用HTML DOM方式添加事件 ?View Code...</small></li>
<li><a href='http://www.51obj.cn/?p=368' rel='bookmark' title='Permanent Link: 如何检查浏览器类型'>如何检查浏览器类型</a> <small>使用检查navigator.userAgent字符串来判断浏览器类型。今天在看一篇文章中提到用户在某些浏览器可以更改userAgent，这样就不能单纯使用这个方法来检查浏览器。在实际使用中一般检查最多的是ie浏览器与标准dom浏览器的区别，这样可以使用window.addEventListener来判断这两种类型的浏览器...</small></li>
</ol></p>
<p>以上关联文章由 <a href='http://mitcho.com/code/yarpp/'>Yet Another Related Posts Plugin</a> 提供支持。</p>]]></content:encoded>
			<wfw:commentRss>http://www.51obj.cn/?feed=rss2&amp;p=848</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
