﻿<?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>Timothy&#039;s Space &#187; C#</title>
	<atom:link href="http://www.xiaozhou.net/tag/c/feed" rel="self" type="application/rss+xml" />
	<link>http://www.xiaozhou.net</link>
	<description>君看一叶舟，出没风波里</description>
	<lastBuildDate>Tue, 07 Feb 2012 04:28:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Ubuntu中mono环境的搭建</title>
		<link>http://www.xiaozhou.net/ittech/linux-ittech/configuration_of_mono_in_ubuntu-2010-08-14.htm</link>
		<comments>http://www.xiaozhou.net/ittech/linux-ittech/configuration_of_mono_in_ubuntu-2010-08-14.htm#comments</comments>
		<pubDate>Sat, 14 Aug 2010 13:38:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Mono]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[搭建]]></category>
		<category><![CDATA[环境]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/ittech/linux-ittech/ubuntu%e4%b8%admono%e7%8e%af%e5%a2%83%e7%9a%84%e6%90%ad%e5%bb%ba-2010-08-14.htm</guid>
		<description><![CDATA[Mono的大名，搞.NET的同学都知道。它使.NET程序在Linux下有了跨平台运行的可能。随着mono的逐步发展，现在已经逐渐趋于稳定和流行了。此文介绍一下Ubuntu中mono环境的搭建。 1.安装 ?View Code BASH1 $ sudo apt-get install mono-gmcs libmono-system-data2.0-cil libmono-system-ldap2.0-cil libmono-system-messaging2.0-cil libmono-system-runtime2.0-cil 当然，还有其他的一些包可选，比如： libmono-winforms2.0-cil 提供WinForm程序开发功能 libmono-system-web2.0-cil 提供asp.net web程序开发功能 libmono-system-web-mvc1.0-cil 提供MVC的web开发框架 libmono-wcf3.0-cil 提供WCF开发功能 libmono-nunit2.4-cil Nunit，单元测试模块 2.安装好后，查看mono相关信息 ?View Code BASH1 2 3 4 5 6 7 8 Mono JIT compiler version 2.4.4 &#40;Debian 2.4.4~svn151842-1ubuntu4&#41; Copyright &#40;C&#41; 2002-2010 Novell, Inc and Contributors. www.mono-project.com TLS: __thread GC: [...]]]></description>
			<content:encoded><![CDATA[<p>Mono的大名，搞.NET的同学都知道。它使.NET程序在Linux下有了跨平台运行的可能。随着mono的逐步发展，现在已经逐渐趋于稳定和流行了。此文介绍一下Ubuntu中mono环境的搭建。</p>
<p>1.安装 </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('p802code4'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8024"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p802code4"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> mono-gmcs libmono-system-data2.0-cil libmono-system-ldap2.0-cil libmono-system-messaging2.0-cil libmono-system-runtime2.0-cil</pre></td></tr></table></div>

<p>当然，还有其他的一些包可选，比如： </p>
<p>libmono-winforms2.0-cil 提供WinForm程序开发功能 </p>
<p>libmono-system-web2.0-cil 提供asp.net web程序开发功能 </p>
<p>libmono-system-web-mvc1.0-cil 提供MVC的web开发框架 </p>
<p>libmono-wcf3.0-cil 提供WCF开发功能 </p>
<p>libmono-nunit2.4-cil Nunit，单元测试模块 </p>
<p>2.安装好后，查看mono相关信息</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('p802code5'); return false;">View Code</a> BASH</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8025"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p802code5"><pre class="bash" style="font-family:monospace;">Mono JIT compiler version 2.4.4 <span style="color: #7a0874; font-weight: bold;">&#40;</span>Debian 2.4.4~svn151842-1ubuntu4<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Copyright <span style="color: #7a0874; font-weight: bold;">&#40;</span>C<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">2002</span>-<span style="color: #000000;">2010</span> Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm <span style="color: #7a0874; font-weight: bold;">&#40;</span>with typed GC<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        SIGSEGV:       altstack
        Notifications: epoll
        Architecture:  x86
        Disabled:      none</pre></td></tr></table></div>

<p>3.测试程序</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('p802code6'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p8026"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code" id="p802code6"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Linq</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">namespace</span> Test
<span style="color: #008000;">&#123;</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: #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;Hello Mono!&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
            Console<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadLine</span><span style="color: #008000;">&#40;</span><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>保存为test.cs，然后用gmcs编译，运行正常。<br />
  <br />至此，mono环境配置成功。</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/ittech/linux-ittech/configuration_of_mono_in_ubuntu-2010-08-14.htm/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Objective-C 学习笔记(一) 第一个Hello World程序</title>
		<link>http://www.xiaozhou.net/mac-development/objectivec/objective_c_learning_note_1_the_first_hello_world_programe-2010-06-23.htm</link>
		<comments>http://www.xiaozhou.net/mac-development/objectivec/objective_c_learning_note_1_the_first_hello_world_programe-2010-06-23.htm#comments</comments>
		<pubDate>Wed, 23 Jun 2010 15:22:23 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[first]]></category>
		<category><![CDATA[hello world]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[learning]]></category>
		<category><![CDATA[note]]></category>
		<category><![CDATA[objective]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[学习笔记]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/mac-development/objectivec/objective-c-%e5%ad%a6%e4%b9%a0%e7%ac%94%e8%ae%b0%e4%b8%80-%e7%ac%ac%e4%b8%80%e4%b8%aahello-world%e7%a8%8b%e5%ba%8f-2010-06-23.htm</guid>
		<description><![CDATA[最近抽空一直在学习Objective-C，打算不久的将来和同事一起搞iPhone应用开发，所以也咬牙入了Mac Mini和iPhone 3GS。教程看的是《Objective-C基础教程》(Learning Objective-C on the Mac)，一本比较初级的教程，也比较适合入门。看了一大半了，不过发现没有动手实际写代码，很多东西还是容易遗忘。正所谓一个好脑袋，不如一支烂笔尖，虽然现在早已不是笔和纸流行的时代，还是打算把自己理解的东西，用学习笔记的形式，把这些记录在偶的Blog中，供以后参考和复习。 废话不多说了，先介绍下Objective-C，Objecive-C是对原有的C语言的扩展，它通过对C语言进行最小集合的扩展，使其本身具有了面向对象的能力。Objective-C并不是一个新的语言，早在20世纪80年代，就诞生了。 这里需要理解几个概念(Key concepts)： Objective-C: 对C语言的扩展，一门面向对象的编程语言 Cocoa: 苹果公司为Objective-C提供的工具包 Cocoa和Objective-C是苹果公司Mac OS X操作系统的核心 Cocoa的前身，是NextSTEP，是Jobs在成立NeXT公司时创建的一款功能强大的用户界面工具包，后来NeXT公司被苹果收购，NextSTEP被更名为Cocoa，这也是Cocoa的由来了。其实在很多Cocoa的函数中，有大量的函数是以&#8221;NS”开头的，NS就是NextSTEP的缩写，属于历史遗留问题了。而这些函数的命名也一直被保留下来。 按照惯例，任何编程语言都是以Hello World开始的，下面是Objective-C的Hello World程序： ?View Code OBJC1 2 3 4 5 6 7 8 #import &#60;fundation fundation.h&#62; &#160; int main&#40;int argc, const char *argv&#91;&#93;&#41; &#123; NSLog&#40;@&#34;Hello World and Objective-C!&#34;&#41;; &#160; return &#40;0&#41;; &#125; // main #import关键字： 类似于C语言里面的include。不过import比include更加智能。为了在C中的多个地方，不重复包含同一个头文件，常常需要用#ifdef等相关的预编译指令来进行判断。Objective-C中更为方便，只需要用import关键字简单实现头文件的包含即可，而不必担心同一个头文件会在多个地方被重复包含。 NSLog函数:&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>最近抽空一直在学习Objective-C，打算不久的将来和同事一起搞iPhone应用开发，所以也咬牙入了Mac Mini和iPhone 3GS。教程看的是《Objective-C基础教程》(Learning Objective-C on the Mac)，一本比较初级的教程，也比较适合入门。看了一大半了，不过发现没有动手实际写代码，很多东西还是容易遗忘。正所谓一个好脑袋，不如一支烂笔尖，虽然现在早已不是笔和纸流行的时代，还是打算把自己理解的东西，用学习笔记的形式，把这些记录在偶的Blog中，供以后参考和复习。    </p>
<p>废话不多说了，先介绍下Objective-C，Objecive-C是对原有的C语言的扩展，它通过对C语言进行最小集合的扩展，使其本身具有了面向对象的能力。Objective-C并不是一个新的语言，早在20世纪80年代，就诞生了。     </p>
<p>这里需要理解几个概念(Key concepts)：     <br /><strong>Objective-C</strong>: 对C语言的扩展，一门面向对象的编程语言     <br /><strong>Cocoa</strong>: 苹果公司为Objective-C提供的工具包     <br /><font color="#ff0000"><strong>Cocoa和Objective-C是苹果公司Mac OS X操作系统的核心        <br /></strong></font>Cocoa的前身，是NextSTEP，是Jobs在成立NeXT公司时创建的一款功能强大的用户界面工具包，后来NeXT公司被苹果收购，NextSTEP被更名为Cocoa，这也是Cocoa的由来了。其实在很多Cocoa的函数中，有大量的函数是以&#8221;NS”开头的，NS就是NextSTEP的缩写，属于历史遗留问题了。而这些函数的命名也一直被保留下来。     </p>
<p>按照惯例，任何编程语言都是以Hello World开始的，下面是Objective-C的Hello World程序：     </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('p701code8'); return false;">View Code</a> OBJC</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p7018"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p701code8"><pre class="objc" style="font-family:monospace;"><span style="color: #6e371a;">#import &lt;fundation fundation.h&gt;</span>
&nbsp;
<span style="color: #a61390;">int</span> main<span style="color: #002200;">&#40;</span><span style="color: #a61390;">int</span> argc, <span style="color: #a61390;">const</span> <span style="color: #a61390;">char</span> <span style="color: #002200;">*</span>argv<span style="color: #002200;">&#91;</span><span style="color: #002200;">&#93;</span><span style="color: #002200;">&#41;</span>
<span style="color: #002200;">&#123;</span>
  NSLog<span style="color: #002200;">&#40;</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;Hello World and Objective-C!&quot;</span><span style="color: #002200;">&#41;</span>;
&nbsp;
  <span style="color: #a61390;">return</span> <span style="color: #002200;">&#40;</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#41;</span>;
<span style="color: #002200;">&#125;</span>  <span style="color: #11740a; font-style: italic;">// main</span></pre></td></tr></table></div>

<p><strong>#import关键字</strong>： 类似于C语言里面的include。不过import比include更加智能。为了在C中的多个地方，不重复包含同一个头文件，常常需要用#ifdef等相关的预编译指令来进行判断。Objective-C中更为方便，只需要用import关键字简单实现头文件的包含即可，而不必担心同一个头文件会在多个地方被重复包含。 </p>
<p><strong>NSLog函数:&#160; </strong>用以输出字符串，其中和C语言有个不一样的地方，字符串前面有个@符号。表示后面的字符串是属于NSString，而不是一般的字符串。NSString类型是Cocoa中特有的字符串类型。</p>
<p>运行程序，输出结果，就是打印一串字符串。</p>
<p>第一篇笔记到此结束，以后继续……</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/mac-development/objectivec/objective_c_learning_note_1_the_first_hello_world_programe-2010-06-23.htm/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>[置顶]常用扩展方法收集&amp;整理(置顶-不断更新)</title>
		<link>http://www.xiaozhou.net/dotnetdevelopment/common_used_extention_method-2009-11-14.htm</link>
		<comments>http://www.xiaozhou.net/dotnetdevelopment/common_used_extention_method-2009-11-14.htm#comments</comments>
		<pubDate>Fri, 13 Nov 2009 16:33:00 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[.NET开发]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Extention]]></category>
		<category><![CDATA[Method]]></category>
		<category><![CDATA[扩展方法]]></category>
		<category><![CDATA[收集]]></category>
		<category><![CDATA[整理]]></category>

		<guid isPermaLink="false">http://www.xiaozhou.net/dotnetdevelopment/%e5%b8%b8%e7%94%a8%e6%89%a9%e5%b1%95%e6%96%b9%e6%b3%95%e6%94%b6%e9%9b%86%e6%95%b4%e7%90%86-%e4%b8%80-2009-11-14.htm</guid>
		<description><![CDATA[常用的扩展方法收集与整理。]]></description>
			<content:encoded><![CDATA[<p>扩展方法，是.NET 3.5中引入的新特性，在<a href="http://www.xiaozhou.net/dotnetdevelopment/extension-method-uses-summary-2009-09-28.htm" target="_blank">《扩展方法使用小结中》</a>，我有具体的介绍。合理的使用扩展方法，能节约不少的代码量，甚至能在开发中给我们带来意想不到的效果，让代码更加的简洁、易懂。其实，网上早就有了不少的大牛写的各种出色的扩展方法，以至于我有了整理一个扩展方法库的想法，把一些实用、优秀的扩展方法收集起来，一来为资源共享，二来也是为了应用在以后的项目代码中，提高开发效率。<span id="more-389"></span></p>
<p>1.Foreach方法<br />
首先上场的是Foreach，在使用Linq的时候，太容易派上用场了。比如，在使用Linq to 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('p389code9'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p3899"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p389code9"><pre class="csharp" style="font-family:monospace;">DataClassDataContext ctx <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataClassDataContext<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
var result <span style="color: #008000;">=</span> ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Products</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>p <span style="color: #008000;">=&gt;</span> p<span style="color: #008000;">.</span><span style="color: #0000FF;">ProductID</span> <span style="color: #008000;">&gt;=</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>var product <span style="color: #0600FF; font-weight: bold;">in</span> result<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>product<span style="color: #008000;">.</span><span style="color: #0000FF;">ProductName</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>自从有了Foreach，可以节省不少的力气了：</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('p389code10'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38910"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p389code10"><pre class="csharp" style="font-family:monospace;">DataClassDataContext ctx <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> DataClassDataContext<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
ctx<span style="color: #008000;">.</span><span style="color: #0000FF;">Products</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">Where</span><span style="color: #008000;">&#40;</span>p <span style="color: #008000;">=&gt;</span> p<span style="color: #008000;">.</span><span style="color: #0000FF;">ProductID</span> <span style="color: #008000;">&gt;=</span> <span style="color: #FF0000;">10</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">ForEach</span><span style="color: #008000;">&#40;</span>p <span style="color: #008000;">=&gt;</span> Console<span style="color: #008000;">.</span><span style="color: #0000FF;">WriteLine</span><span style="color: #008000;">&#40;</span>p<span style="color: #008000;">.</span><span style="color: #0000FF;">ProductName</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>Foreach代码如下:</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('p389code11'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38911"><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code" id="p389code11"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">void</span> <span style="color: #0600FF; font-weight: bold;">ForEach</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> IEnumerable source, Action action<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
        <span style="color: #0600FF; font-weight: bold;">foreach</span><span style="color: #008000;">&#40;</span>var item <span style="color: #0600FF; font-weight: bold;">in</span> source<span style="color: #008000;">&#41;</span>
        <span style="color: #008000;">&#123;</span>
            action<span style="color: #008000;">&#40;</span>item<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
        <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<p>2.In方法<br />
判断某个类型的变量是否在一个序列中</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('p389code12'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38912"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p389code12"><pre class="csharp" style="font-family:monospace;"><span style="color: #6666cc; font-weight: bold;">string</span> <span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> names <span style="color: #008000;">=</span> <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> <span style="color: #6666cc; font-weight: bold;">string</span><span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> <span style="color: #008000;">&#123;</span><span style="color: #666666;">&quot;Andy&quot;</span>, <span style="color: #666666;">&quot;Timothy&quot;</span>, <span style="color: #666666;">&quot;Ben&quot;</span>, <span style="color: #666666;">&quot;Rex&quot;</span>, <span style="color: #666666;">&quot;Ven&quot;</span>, <span style="color: #666666;">&quot;Ken&quot;</span><span style="color: #008000;">&#125;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>names<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Timothy&quot;</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;Found!&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>使用In方法:</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('p389code13'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38913"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p389code13"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">if</span> <span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Timothy&quot;</span><span style="color: #008000;">.</span><span style="color: #0600FF; font-weight: bold;">In</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;Andy&quot;</span>, <span style="color: #666666;">&quot;Timothy&quot;</span>, <span style="color: #666666;">&quot;Ben&quot;</span>, <span style="color: #666666;">&quot;Rex&quot;</span>, <span style="color: #666666;">&quot;Ven&quot;</span>, <span style="color: #666666;">&quot;Ken&quot;</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;Found!&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>In方法代码如下:</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('p389code14'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38914"><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code" id="p389code14"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> <span style="color: #6666cc; font-weight: bold;">bool</span> <span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> T t, <span style="color: #0600FF; font-weight: bold;">params</span> T<span style="color: #008000;">&#91;</span><span style="color: #008000;">&#93;</span> c<span style="color: #008000;">&#41;</span>
<span style="color: #008000;">&#123;</span>
    <span style="color: #0600FF; font-weight: bold;">return</span> c<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</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></pre></td></tr></table></div>

<p>3.WinForm下的控件选择器(摘自 博客园-鹤冲天 的博客 http://www.cnblogs.com/ldp615/archive/2009/11/08/1598596.html)</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('p389code15'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38915"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code" id="p389code15"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">static</span> IEnumerable GetControls<span style="color: #008000;">&#40;</span><span style="color: #0600FF; font-weight: bold;">this</span> Control control, Func filter<span style="color: #008000;">&#41;</span> <span style="color: #0600FF; font-weight: bold;">where</span> T <span style="color: #008000;">:</span> Control
<span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>Control c <span style="color: #0600FF; font-weight: bold;">in</span> control<span style="color: #008000;">.</span><span style="color: #0000FF;">Controls</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>c <a href="http://www.google.com/search?q=is+msdn.microsoft.com"><span style="color: #008000;">is</span></a> T<span style="color: #008000;">&amp;&amp;</span><span style="color: #008000;">&#40;</span>filter <span style="color: #008000;">==</span> <span style="color: #0600FF; font-weight: bold;">null</span><span style="color: #008000;">||</span>filter<span style="color: #008000;">&#40;</span>c <span style="color: #0600FF; font-weight: bold;">as</span> T<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
		<span style="color: #008000;">&#123;</span>
 			<span style="color: #0600FF; font-weight: bold;">yield</span> <span style="color: #0600FF; font-weight: bold;">return</span> c <span style="color: #0600FF; font-weight: bold;">as</span> T<span style="color: #008000;">;</span>
 		<span style="color: #008000;">&#125;</span>
 		<span style="color: #0600FF; font-weight: bold;">foreach</span> <span style="color: #008000;">&#40;</span>T _t <span style="color: #0600FF; font-weight: bold;">in</span> GetControls<span style="color: #008000;">&#40;</span>c, filter<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
 		<span style="color: #0600FF; font-weight: bold;">yield</span> <span style="color: #0600FF; font-weight: bold;">return</span> _t<span style="color: #008000;">;</span>
 	<span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</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('p389code16'); return false;">View Code</a> CSHARP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p38916"><td class="line_numbers"><pre>1
2
</pre></td><td class="code" id="p389code16"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">this</span><span style="color: #008000;">.</span><span style="color: #0000FF;">GetControls</span><span style="color: #008000;">&lt;</span>button<span style="color: #008000;">&gt;</span><span style="color: #008000;">&#40;</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;">ForEach</span><span style="color: #008000;">&#40;</span>b <span style="color: #008000;">=&gt;</span> b<span style="color: #008000;">.</span><span style="color: #0000FF;">Enabled</span> <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>  <span style="color: #008080; font-style: italic;">//禁用界面上所有Button控件</span>
<span style="color: #008000;">&lt;/</span>button<span style="color: #008000;">&gt;</span></pre></td></tr></table></div>

<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/dotnetdevelopment/common_used_extention_method-2009-11-14.htm/feed</wfw:commentRss>
		<slash:comments>38</slash:comments>
		</item>
		<item>
		<title>C# IDE Mobile – Write your C# code anywhere!</title>
		<link>http://www.xiaozhou.net/dotnetdevelopment/c-ide-mobile-write-your-c-code-anywhere-2009-05-29.htm</link>
		<comments>http://www.xiaozhou.net/dotnetdevelopment/c-ide-mobile-write-your-c-code-anywhere-2009-05-29.htm#comments</comments>
		<pubDate>Fri, 29 May 2009 15:06:23 +0000</pubDate>
		<dc:creator>Timothy</dc:creator>
				<category><![CDATA[.NET开发]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[IDE]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://localhost/wordpress/?p=232</guid>
		<description><![CDATA[最近败了个QWERTY全键盘的HTC Touch pro，全键盘的感觉不错，输入速度比以前靠触摸笔点屏幕快多了。装了个Python的Windows mobile版本，没事学着写Python玩玩。一日突发奇想，要是能在PPC手机上写C#的程序并能运行起来，那就太棒了。果然不出我所料，国外已经有大侠已经做好了这个东东，一个运行在Windows Mobile手机上的简单的C# IDE，让你可以随时在你的PPC手机上写C#的程序。这是作者自己实现的一个简单IDE，现在已经支持的功能如下： * 可以创建基于图形用户界面的程序 * 可创建方法和类 * 可以调用所有的.NET Compact Framework的类。 * 执行文件操作 * 运行进程 * 使用.NET 2.0中的范型 * 支持C#的控制语句，包括循环、条件判断&#8230;&#8230; IDE的使用非常简单，写入你的代码，然后可以立即运行，看到结果。 简单的例子，如下： 1: using System.Windows.Forms; 2: namespace TestNS 3: { 4: class TestCL 5: { 6: public static void Main() 7: { 8: MessageBox.Show(&#34;Hello Timothy!&#34;); 9: } 10: } 11: } &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>最近败了个QWERTY全键盘的HTC Touch pro，全键盘的感觉不错，输入速度比以前靠触摸笔点屏幕快多了。装了个Python的Windows mobile版本，没事学着写Python玩玩。一日突发奇想，要是能在PPC手机上写C#的程序并能运行起来，那就太棒了。果然不出我所料，国外已经有大侠已经做好了这个东东，一个运行在Windows Mobile手机上的简单的C# IDE，让你可以随时在你的PPC手机上写C#的程序。这是作者自己实现的一个简单IDE，现在已经支持的功能如下：</p>
<p>* 可以创建基于图形用户界面的程序</p>
<p>* 可创建方法和类</p>
<p>* 可以调用所有的.NET Compact Framework的类。</p>
<p>* 执行文件操作</p>
<p>* 运行进程</p>
<p>* 使用.NET 2.0中的范型</p>
<p>* 支持C#的控制语句，包括循环、条件判断&hellip;&hellip;</p>
<p>IDE的使用非常简单，写入你的代码，然后可以立即运行，看到结果。</p>
<p>简单的例子，如下：</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">using</span> System.Windows.Forms;</pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">namespace</span> TestNS</pre>
<pre class="alt"><span class="lnum">   3:  </span>{</pre>
<pre><span class="lnum">   4:  </span>    <span class="kwrd">class</span> TestCL</pre>
<pre class="alt"><span class="lnum">   5:  </span>    {</pre>
<pre><span class="lnum">   6:  </span>       <span class="kwrd">public</span> <span class="kwrd">static</span> <span class="kwrd">void</span> Main()</pre>
<pre class="alt"><span class="lnum">   7:  </span>       {</pre>
<pre><span class="lnum">   8:  </span>            MessageBox.Show(<span class="str">&quot;Hello Timothy!&quot;</span>);</pre>
<pre class="alt"><span class="lnum">   9:  </span>       }</pre>
<pre><span class="lnum">  10:  </span>    }</pre>
<pre class="alt"><span class="lnum">  11:  </span>}</pre>
</div>
<style type="text/css">
<p>.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }</style>
</p>
<p>&nbsp;</p>
<p>点击菜单下面的Debug-&gt;Run,运行结果截图如下：</p>
<p><a href="/pics/CIDEMobileWriteyourCcodeanywh&#101;re_13065/1.jpg"><img title="1" border="0" alt="1" width="324" height="431" style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" src="/pics/CIDEMobileWriteyourCcodeanywh&#101;re_13065/1_thumb.jpg" /></a></p>
<p>&nbsp;</p>
<p>IDE自带一些简单的功能， 包括插入代码模板，编辑(复制、粘贴、剪切)功能，还支持插件功能。</p>
<p><a href="/pics/CIDEMobileWriteyourCcodeanywh&#101;re_13065/2.jpg"><img title="2" border="0" alt="2" width="324" height="431" style="border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto" src="/pics/CIDEMobileWriteyourCcodeanywh&#101;re_13065/2_thumb.jpg" /></a></p>
<p>&nbsp;</p>
<p>软件下载地址： <a title="http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile.zip" href="http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile.zip">http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile.zip</a></p>
<p>Code Sample: <a title="http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile_samples.zip" href="http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile_samples.zip">http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile_samples.zip</a></p>
<p>用户手册、帮助文档地址： <a title="http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile_manual/index.htm" href="http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile_manual/index.htm">http://www.geocities.com/hrowson/wm5_software/cs_ide_mobile_manual/index.htm</a></p>
<p>作者主页：<a title="http://www.geocities.com/hrowson/wm5_software/index.htm" href="http://www.geocities.com/hrowson/wm5_software/index.htm">http://www.geocities.com/hrowson/wm5_software/index.htm</a></p>
<p>赶紧下载吧，write your C# code anywh&#101;re! 活活~~</p>
<p class="announce"><span style="font-weight:bold;text-shadow:0 1px 0 #ddd;">声明:</span> 此Blog中的文章和随笔仅代表作者在某一特定时间内的观点和结论，对其完全的正确不做任何担保或假设 <br /> 本站文章均采用 <a rel="nofollow" href="http://creativecommons.org/licenses/by-nc-sa/3.0/" title="署名-非商业性使用-相同方式共享">知识共享署名-相同方式共享3.0</a> 协议进行授权，除非注明，本站文章均为原创，转载请注明转自  <a href="http://www.xiaozhou.net">Timothy&#039;s Space</a> 并应以链接形式标明本文地址!</p>]]></content:encoded>
			<wfw:commentRss>http://www.xiaozhou.net/dotnetdevelopment/c-ide-mobile-write-your-c-code-anywhere-2009-05-29.htm/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

