<?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>追風箏的小孩 &#187; C#</title>
	<atom:link href="http://m955.com/wp/archives/tag/c/feed" rel="self" type="application/rss+xml" />
	<link>http://m955.com/wp</link>
	<description></description>
	<lastBuildDate>Thu, 03 Nov 2011 14:47:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>使用 ZedGraph 製作統計圖</title>
		<link>http://m955.com/wp/archives/237</link>
		<comments>http://m955.com/wp/archives/237#comments</comments>
		<pubDate>Wed, 22 Jul 2009 08:23:30 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[圖表]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/237</guid>
		<description><![CDATA[這幾天研究了 ZedGraph，發現它是一套很好用的畫圖表工具，練習做了一個統計圖，大家參考看看！

PLAIN TEXT
C#:




//記得要加入參考


using ZedGraph;


&#160;


//資料來源&#160; &#160; &#160; &#160; 


privat... ]]></description>
			<content:encoded><![CDATA[<p>這幾天研究了 ZedGraph，發現它是一套很好用的畫圖表工具，練習做了一個統計圖，大家參考看看！</p>
<p><a href="http://farm4.static.flickr.com/3529/3744942595_3e8b5a6bcb_o.png" target="_blank" rel="lightbox"><img src="http://farm4.static.flickr.com/3529/3744942595_226b42dbe7.jpg"></a></p>
<div class="igBar"><span id="lcsharp-2"><a href="#" onclick="javascript:showPlainTxt('csharp-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-2">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//記得要加入參考</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> ZedGraph;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//資料來源&nbsp; &nbsp; &nbsp; &nbsp; </span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">private</span> DataTable getDT<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DataTable dt = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> DataTable<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"學號"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.String"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"姓名"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.String"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"國文"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.Int32"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"英文"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.Int32"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Columns</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"數學"</span>, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Type</span>.<span style="color: #0000FF;">GetType</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"System.Int32"</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510001"</span>, <span style="color: #808080;">"崔昱翰"</span>, <span style="color: #FF0000;color:#800000;">85</span>, <span style="color: #FF0000;color:#800000;">66</span>, <span style="color: #FF0000;color:#800000;">71</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510002"</span>, <span style="color: #808080;">"王詩光"</span>, <span style="color: #FF0000;color:#800000;">65</span>, <span style="color: #FF0000;color:#800000;">92</span>, <span style="color: #FF0000;color:#800000;">88</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510003"</span>, <span style="color: #808080;">"劉育白"</span>, <span style="color: #FF0000;color:#800000;">52</span>, <span style="color: #FF0000;color:#800000;">66</span>, <span style="color: #FF0000;color:#800000;">63</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510004"</span>, <span style="color: #808080;">"許威宇"</span>, <span style="color: #FF0000;color:#800000;">98</span>, <span style="color: #FF0000;color:#800000;">70</span>, <span style="color: #FF0000;color:#800000;">61</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510005"</span>, <span style="color: #808080;">"李佩珊"</span>, <span style="color: #FF0000;color:#800000;">81</span>, <span style="color: #FF0000;color:#800000;">63</span>, <span style="color: #FF0000;color:#800000;">76</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"B9510006"</span>, <span style="color: #808080;">"潘紹興"</span>, <span style="color: #FF0000;color:#800000;">91</span>, <span style="color: #FF0000;color:#800000;">77</span>, <span style="color: #FF0000;color:#800000;">76</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">return</span> dt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//學生成績</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #0600FF;">void</span> StudentChart1<span style="color: #000000;">&#40;</span>ZedGraphControl zgc<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Google網域搜尋：Fill site:http://zedgraph.sourceforge.net/documentation</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; GraphPane myPane = zgc.<span style="color: #0000FF;">GraphPane</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; DataTable dt = getDT<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Set the title and axis labels</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">Title</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"學生成績量化表"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">Title</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"學生姓名"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">YAxis</span>.<span style="color: #0000FF;">Title</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #808080;">"分數"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PointPairList list1 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> PointPairList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PointPairList list2 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> PointPairList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; PointPairList list3 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> PointPairList<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Random rand = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Random<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Generate random data for three curves</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;color:#800000;">0</span>; i &lt;dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Count</span>; i++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> x = <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">double</span><span style="color: #000000;">&#41;</span>i;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> y1_chian = Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"國文"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> y2_eng = Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"英文"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">double</span> y3_math = Convert.<span style="color: #0000FF;">ToDouble</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"數學"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; list1.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>x, y1_chian<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; list2.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>x, y2_eng<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; list3.<span style="color: #0000FF;">Add</span><span style="color: #000000;">&#40;</span>x, y3_math<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// create the curves</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// BarItem.Bar.Fill(Color) 填入單一顏色</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// BarItem.Bar.Fill(Color, Color, Color, 90) 填入漸層顏色，第4參數是旋轉角度</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem myCurve1 = myPane.<span style="color: #0000FF;">AddBar</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"國文"</span>, list1, Color.<span style="color: #0000FF;">Red</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myCurve1.<span style="color: #0000FF;">Bar</span>.<span style="color: #0000FF;">Fill</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Fill<span style="color: #000000;">&#40;</span>Color.<span style="color: #0000FF;">FromArgb</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">255</span>, <span style="color: #FF0000;color:#800000;">238</span>, <span style="color: #FF0000;color:#800000;">221</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem myCurve2 = myPane.<span style="color: #0000FF;">AddBar</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"英文"</span>, list2, Color.<span style="color: #0000FF;">Blue</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myCurve2.<span style="color: #0000FF;">Bar</span>.<span style="color: #0000FF;">Fill</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Fill<span style="color: #000000;">&#40;</span>Color.<span style="color: #0000FF;">FromArgb</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">221</span>, <span style="color: #FF0000;color:#800000;">255</span>, <span style="color: #FF0000;color:#800000;">238</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem myCurve3 = myPane.<span style="color: #0000FF;">AddBar</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"數學"</span>, list3, Color.<span style="color: #0000FF;">Green</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myCurve3.<span style="color: #0000FF;">Bar</span>.<span style="color: #0000FF;">Fill</span> = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> Fill<span style="color: #000000;">&#40;</span>Color.<span style="color: #0000FF;">FromArgb</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">238</span>, <span style="color: #FF0000;color:#800000;">221</span>, <span style="color: #FF0000;color:#800000;">255</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Fill the axis background with a color gradient</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// 背景色</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// myPane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 255, 166), 45.0F);</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">MajorTic</span>.<span style="color: #0000FF;">IsBetweenLabels</span> = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//加入X LabelText</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> labels = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;color:#800000;">6</span><span style="color: #000000;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;color:#800000;">0</span>; i &lt;dt.<span style="color: #0000FF;">Rows</span>.<span style="color: #0000FF;">Count</span>; i++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; labels<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> = Convert.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span>dt.<span style="color: #0000FF;">Rows</span><span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span><span style="color: #000000;">&#91;</span><span style="color: #808080;">"姓名"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">Scale</span>.<span style="color: #0000FF;">TextLabels</span> = labels; <span style="color: #008080; font-style: italic;">//X軸的說明文字</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">Type</span> = AxisType.<span style="color: #0000FF;">Text</span>;&nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//X軸類型</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//重新計算目前數據範圍</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; zgc.<span style="color: #0000FF;">AxisChange</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// expand the range of the Y axis slightly to accommodate the labels</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// myPane.YAxis.Scale.Max += myPane.YAxis.Scale.MajorStep;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// YAxis最大值</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">YAxis</span>.<span style="color: #0000FF;">Scale</span>.<span style="color: #0000FF;">Max</span> = <span style="color: #FF0000;color:#800000;">110</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// Create TextObj's to provide labels for each bar</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">// 在bar上顯示數值</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; BarItem.<span style="color: #0000FF;">CreateBarLabels</span><span style="color: #000000;">&#40;</span>myPane, <span style="color: #0600FF;">false</span>, <span style="color: #808080;">"f0"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//顯示格點</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">YAxis</span>.<span style="color: #0000FF;">MajorGrid</span>.<span style="color: #0000FF;">IsVisible</span> = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; myPane.<span style="color: #0000FF;">XAxis</span>.<span style="color: #0000FF;">MajorGrid</span>.<span style="color: #0000FF;">IsVisible</span> = <span style="color: #0600FF;">true</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/237/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>連結資料庫四大步驟（以 ASP.NET 為例）</title>
		<link>http://m955.com/wp/archives/219</link>
		<comments>http://m955.com/wp/archives/219#comments</comments>
		<pubDate>Mon, 22 Jun 2009 13:54:33 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=219</guid>
		<description><![CDATA[其實 WinForm 跟 WebForm 在連結資料庫方面其實差不了太多。
PLAIN TEXT
C#:




protected void Page_Load&#40;object sender, EventArgs e&#41;


&#123;


&#160; &#160; //第一：連結SQL資料庫


&#160; &#160; string connstr = @"Data Sou... ]]></description>
			<content:encoded><![CDATA[<p>其實 WinForm 跟 WebForm 在連結資料庫方面其實差不了太多。</p>
<div class="igBar"><span id="lcsharp-4"><a href="#" onclick="javascript:showPlainTxt('csharp-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-4">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">void</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第一：連結SQL資料庫</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">string</span> connstr = <span style="color: #808080;">@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\test_Data.MDF;Integrated Security=True;Connect Timeout=30;User Instance=True"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; SqlConnection conn = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> SqlConnection<span style="color: #000000;">&#40;</span>connstr<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conn.<span style="color: #0000FF;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第二：執行SQL指令</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">string</span> sqlstr = <span style="color: #808080;">"select * from test"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; SqlCommand cmd = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> SqlCommand<span style="color: #000000;">&#40;</span>sqlstr,conn<span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; SqlDataReader dr = cmd.<span style="color: #0000FF;">ExecuteReader</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第三：印出資料</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">while</span> <span style="color: #000000;">&#40;</span>dr.<span style="color: #0000FF;">Read</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Response.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"文章編號："</span> + dr<span style="color: #000000;">&#91;</span><span style="color: #808080;">"id"</span><span style="color: #000000;">&#93;</span> + <span style="color: #808080;">"&lt;br&gt;"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Response.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"日　　期："</span> + dr<span style="color: #000000;">&#91;</span><span style="color: #808080;">"test_time"</span><span style="color: #000000;">&#93;</span> + <span style="color: #808080;">"&lt;br&gt;"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Response.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"文章標題："</span> + dr<span style="color: #000000;">&#91;</span><span style="color: #808080;">"title"</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Response.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"&lt;hr&gt;"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第四：關閉連線</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; cmd.<span style="color: #0000FF;">Cancel</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; dr.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conn.<span style="color: #0000FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; conn.<span style="color: #0000FF;">Dispose</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>文章參考於：<a href="http://findbook.tw/book/9789862042380/basic" target="_blank">ASP.NET專題實務-適用C# 作者：周棟祥</a></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/219/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>驗證 ASP.NET Web 網頁中的使用者輸入</title>
		<link>http://m955.com/wp/archives/210</link>
		<comments>http://m955.com/wp/archives/210#comments</comments>
		<pubDate>Sun, 21 Jun 2009 16:04:58 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[ADO.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=210</guid>
		<description><![CDATA[工具：RequiredFieldValidator
驗證：必要輸入項
說明：確保使用者不會略過輸入項目。如需詳細資訊，請參閱 HOW TO：驗證 ASP.NET 伺服器控制項的必要項目。
工具：CompareValidator
驗證：與某個值的比... ]]></description>
			<content:encoded><![CDATA[<p>工具：<a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.requiredfieldvalidator.aspx" target="_blank">RequiredFieldValidator</a><br />
驗證：必要輸入項<br />
說明：確保使用者不會略過輸入項目。<a href="http://msdn.microsoft.com/zh-tw/library/e78xxk8k.aspx" target="_blank">如需詳細資訊，請參閱 HOW TO：驗證 ASP.NET 伺服器控制項的必要項目。</a></p>
<p>工具：<a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.comparevalidator.aspx" target="_blank">CompareValidator</a><br />
驗證：與某個值的比較<br />
說明：使用比較運算子 (例如小於、等於、大於)，將使用者輸入的值與常數值、另一個控制項的值，或特定資料型別做比較。<a href="http://msdn.microsoft.com/zh-tw/library/ad548tzy.aspx" target="_blank">如需詳細資訊，請參閱 HOW TO：比對特定值驗證 ASP.NET 伺服器控制項和 HOW TO：比對資料型別驗證 ASP.NET 伺服器控制項。</a></p>
<p>工具：<a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.rangevalidator.aspx" target="_blank">RangeValidator</a><br />
驗證：範圍檢查<br />
說明：檢查使用者的輸入是否介於指定的上下限之間。您可以檢查成對的數字、英文字母字元和日期內的範圍。如需詳細資訊，<a href="http://msdn.microsoft.com/zh-tw/library/bk58fdzx.aspx" target="_blank">請參閱 HOW TO：比對範圍值驗證 ASP.NET 伺服器控制項。</a></p>
<p>工具：<a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.regularexpressionvalidator.aspx" target="_blank">RegularExpressionValidator</a><br />
驗證：樣式比對<br />
說明：檢查輸入是否符合規則運算式 (Regular Expression) 所定義的樣式。這類的驗證可讓您檢查字元 (例如電子郵件地址、電話號碼、郵遞區號等項目中的字元) 的預期順序。<a href="http://msdn.microsoft.com/zh-tw/library/6xh899wy.aspx" target="_blank">如需詳細資訊，請參閱 HOW TO：比對模式驗證 ASP.NET 伺服器控制項。</a></p>
<p>工具：<a href="http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.customvalidator.aspx" target="_blank">CustomValidator</a><br />
驗證：使用者定義<br />
說明：使用您自己撰寫的邏輯驗證使用者的輸入。這類驗證可讓您檢查執行階段時衍生的值。如需詳細資訊，<a href="http://msdn.microsoft.com/zh-tw/library/f5db6z8k.aspx" target="_blank">請參閱 HOW TO：使用 ASP.NET 伺服器控制項的自訂函式驗證</a>和 <a href="http://msdn.microsoft.com/zh-tw/library/s5z00s5e.aspx" target="_blank">HOW TO：比對資料庫值驗證 ASP.NET 伺服器控制項。</a></p>
<p><a href="http://msdn.microsoft.com/zh-tw/library/bwd43d0x.aspx" target="_blank"><br />
MSDN</a></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/210/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在 VS2005 工具列中增加 AJAX 擴充功能</title>
		<link>http://m955.com/wp/archives/203</link>
		<comments>http://m955.com/wp/archives/203#comments</comments>
		<pubDate>Sat, 20 Jun 2009 17:17:20 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=203</guid>
		<description><![CDATA[
　　在 VS20085 工具列中，AJAX 擴充功能這個選項是內建的，不過在 VS2005 中並沒有，現在坊間的書籍大多以 VS2008 為主，會常用到 AJAX 功能，不過如果不更換版本，在 VS2005 中也可以安裝 AJAX 擴... ]]></description>
			<content:encoded><![CDATA[<p><img alt="" src="http://farm3.static.flickr.com/2244/3644497936_c8bb9ba096_o.png" class="alignnone" width="165" height="138" /></p>
<p>　　在 VS20085 工具列中，AJAX 擴充功能這個選項是內建的，不過在 VS2005 中並沒有，現在坊間的書籍大多以 VS2008 為主，會常用到 AJAX 功能，不過如果不更換版本，在 VS2005 中也可以安裝 AJAX 擴充功能。你必須下載以下檔案（約1MB多）安裝完成後，AJAX 擴充功能就會出現了。</p>
<p>下載檔案：<a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&#038;displaylang=en" target="_blank"><br />
ASP.NET AJAX 1.0</a></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/203/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>[寫程式] 藝術？還是快速開發？</title>
		<link>http://m955.com/wp/archives/201</link>
		<comments>http://m955.com/wp/archives/201#comments</comments>
		<pubDate>Sat, 20 Jun 2009 09:19:22 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=201</guid>
		<description><![CDATA[　　用 Visual Studio 久了會發現一個問題，就是會越來越依賴這個開發工具，因為它什麼都幫你處理好了，程式指令永遠只記得前面三個字母，因為VS有指令自動補齊，連接資料庫有精靈幫忙，管... ]]></description>
			<content:encoded><![CDATA[<p>　　用 Visual Studio 久了會發現一個問題，就是會越來越依賴這個開發工具，因為它什麼都幫你處理好了，程式指令永遠只記得前面三個字母，因為VS有指令自動補齊，連接資料庫有精靈幫忙，管你是 MSSQL 還是 Access，全部按一按搞定，還順便幫你把 Insert、Update、Select、Delete…等 SQL 四大溝通指令寫好了，程式就這麼在拖拉、設定之間開發完成，有的甚至不用寫任何一行指令。</p>
<p>　　以前我很排斥用精靈方式來寫程式，堅持一字一句 Key 出來，不過我發現這會花費很多時間，舉個例子來說好了，寫一個簡單的通訊錄，不包括建資料庫的時間，用傳統手 Key 方式，我大概要花上半天的時間，因為我要拉控制項、設定控制項名稱、寫資料庫連接、資料繫結、資料配接器的 Insert、Update、Select、Delete 四個屬性質、設定 BindSource 導覽列…等，寫完天都黑了。</p>
<p>　　不過如果換成精靈模式寫，大概只要30分鐘就可以搞定，在產出力方面，精靈模式大勝，不過在程式靈活度、和可讀性來說，還是傳統手 Key 方式略勝一籌。</p>
<p>　　站在公司的立場，當然希望程式設計師的產出力越多越好，有些小地方還是用拖拉的就好，藝術這種東西不能當飯吃，VS是一個很邪惡的東西，因為他讓新手認為寫程式是一件很簡單的東西，讓老手離不開它。</p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/201/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C# string.Format輸出格式</title>
		<link>http://m955.com/wp/archives/176</link>
		<comments>http://m955.com/wp/archives/176#comments</comments>
		<pubDate>Fri, 19 Jun 2009 03:46:49 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=176</guid>
		<description><![CDATA[PLAIN TEXT
C#:




前面補0的數字字串


String.Format&#40;"{0:0000}", 157&#41;; // 輸出 0157


&#160;


前後都補0的數字字串


String.Format&#40;"{0:0000.0000}", 157.42&#41;; // 輸出 0157.4200


&#160;


每3位數&#40;千&#41;加逗... ]]></description>
			<content:encoded><![CDATA[<div class="igBar"><span id="lcsharp-7"><a href="#" onclick="javascript:showPlainTxt('csharp-7'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-7">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">前面補<span style="color: #FF0000;color:#800000;">0</span>的數字字串</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:0000}"</span>, <span style="color: #FF0000;color:#800000;">157</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// 輸出 0157</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">前後都補<span style="color: #FF0000;color:#800000;">0</span>的數字字串</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:0000.0000}"</span>, <span style="color: #FF0000;color:#800000;">157</span>.<span style="color: #FF0000;color:#800000;">42</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// 輸出 0157.4200</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">每<span style="color: #FF0000;color:#800000;">3</span>位數<span style="color: #000000;">&#40;</span>千<span style="color: #000000;">&#41;</span>加逗號</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:0,0}"</span>, <span style="color: #FF0000;color:#800000;">38560</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// 輸出 38,560</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">格式化電話號碼</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:(###) ###-####}"</span>, <span style="color: #FF0000;color:#800000;">8005551212</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// 輸出 (800) 555-1212</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">金額的表示</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:$#,##0.00;($#,##0.00);Zero}"</span>, <span style="color: #FF0000;color:#800000;">0</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// 這個會顯示 Zero</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:$#,##0.00;($#,##0.00);Zero}"</span>, <span style="color: #FF0000;color:#800000;">1243</span>.<span style="color: #FF0000;color:#800000;">50</span><span style="color: #000000;">&#41;</span>; <span style="color: #008080; font-style: italic;">// 這個會顯示 $1,243.50 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>依照上面格式範例 ~ 套用到我的報表要呈現的欄位 ~ 如以下 ~</p>
<div class="igBar"><span id="lcsharp-8"><a href="#" onclick="javascript:showPlainTxt('csharp-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-8">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> DataGrid_ItemDataBound<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, <span style="color: #000000;">System</span>.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">WebControls</span>.<span style="color: #0000FF;">DataGridItemEventArgs</span> e<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Item</span>.<span style="color: #0000FF;">ItemIndex</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> != <span style="color: #808080;">"-1"</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; e.<span style="color: #0000FF;">Item</span>.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;color:#800000;">0</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Text</span> = <span style="color: #FF0000;">string</span>.<span style="color: #0000FF;">Format</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"{0:#,0.0}"</span>,<span style="color: #FF0000;">double</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Item</span>.<span style="color: #0000FF;">Cells</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;color:#800000;">3</span><span style="color: #000000;">&#93;</span>.<span style="color: #0000FF;">Text</span>.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;<span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>參考資料來源：<br />
http://blog.stevex.net/index.php/string-formatting-in-csharp/</p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/176/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C# 如何取得兩個 DateTime 日期之間相差的天數</title>
		<link>http://m955.com/wp/archives/186</link>
		<comments>http://m955.com/wp/archives/186#comments</comments>
		<pubDate>Wed, 04 Feb 2009 14:09:48 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=186</guid>
		<description><![CDATA[PLAIN TEXT
C#:




DateTime dt1 = new DateTime&#40;2008, 12, 31&#41;;


DateTime dt2 = new DateTime&#40;2009, 2, 13&#41;;


TimeSpan s = new TimeSpan&#40;dt2.Ticks - dt1.Ticks&#41;;


MessageBox.Show&#40;Convert.ToString&#40;s.Days&#41;&#41;;


&#160;


... ]]></description>
			<content:encoded><![CDATA[<div class="igBar"><span id="lcsharp-10"><a href="#" onclick="javascript:showPlainTxt('csharp-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-10">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">DateTime dt1 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> DateTime<span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">2008</span>, <span style="color: #FF0000;color:#800000;">12</span>, <span style="color: #FF0000;color:#800000;">31</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">DateTime dt2 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> DateTime<span style="color: #000000;">&#40;</span><span style="color: #FF0000;color:#800000;">2009</span>, <span style="color: #FF0000;color:#800000;">2</span>, <span style="color: #FF0000;color:#800000;">13</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">TimeSpan s = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> TimeSpan<span style="color: #000000;">&#40;</span>dt2.<span style="color: #0000FF;">Ticks</span> - dt1.<span style="color: #0000FF;">Ticks</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>Convert.<span style="color: #0000FF;">ToString</span><span style="color: #000000;">&#40;</span>s.<span style="color: #0000FF;">Days</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #008080; font-style: italic;">//回傳44天，相反則為負值 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>　</p>
<p>參考網址：<br />
<a href="http://blog.miniasp.com/post/2008/01/Find-the-difference-between-two-DateTime.aspx" target="_blank">C# 如何取得兩個 DateTime 日期之間的天數</a><br />
<a href="http://msdn.microsoft.com/zh-tw/library/system.timespan.aspx" target="_blank">TimeSpan MSDN</a></p>
<p>　</p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/186/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>列舉 (enum) 資料型別</title>
		<link>http://m955.com/wp/archives/184</link>
		<comments>http://m955.com/wp/archives/184#comments</comments>
		<pubDate>Mon, 02 Feb 2009 14:55:16 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=184</guid>
		<description><![CDATA[　　enum 是一種用來宣告列舉型別 (Enumeration Type) 的關鍵字，是一組列舉清單項目的具名常數所構成的特殊型別，emun 主要目的在提高程式的可讀性，及易維護性，使用 enum 有以下幾點需要注意... ]]></description>
			<content:encoded><![CDATA[<p>　　enum 是一種用來宣告列舉型別 (Enumeration Type) 的關鍵字，是一組列舉清單項目的具名常數所構成的特殊型別，emun 主要目的在提高程式的可讀性，及易維護性，使用 enum 有以下幾點需要注意：</p>
<ol>
<li>enum 不能使用於方法 (Method) 內宣告。</li>
<li>資料型別必須是 byte,sbyte,short,ushort,int,uint,long 或 ulong。</li>
<li>預設資料型別為 int。</li>
<li>float 與 double 不可為 enum 的資料型別。</li>
</ol>
<p>關於列舉的宣告方式如下：</p>
<table id="table_code" border="1">
<tr>
<td>
[存取修飾詞] enum [列舉名稱] : [資料型別]<br />
{<br />
　　[成員1],<br />
　　[成員2],<br />
　　...<br />
　　[成員n]<br />
}
  </td>
</tr>
</table>
<p>　</p>
<p>關列舉範例程式如下：</p>
<div class="igBar"><span id="lcsharp-12"><a href="#" onclick="javascript:showPlainTxt('csharp-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-12">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">enum</span> student : <span style="color: #FF0000;">short</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 周杰倫 = <span style="color: #FF0000;color:#800000;">1</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 方文山 = <span style="color: #FF0000;color:#800000;">2</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 蔡依林 = <span style="color: #FF0000;color:#800000;">3</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 王立宏 = <span style="color: #FF0000;color:#800000;">4</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> button1_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//將combox的文字數字轉換成短整數</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">short</span> num = <span style="color: #FF0000;color:#800000;">0</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>cbox.<span style="color: #0000FF;">Text</span> != <span style="color: #808080;">""</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; num = <span style="color: #FF0000;">short</span>.<span style="color: #0000FF;">Parse</span><span style="color: #000000;">&#40;</span>cbox.<span style="color: #0000FF;">Text</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">switch</span> <span style="color: #000000;">&#40;</span>num<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">case</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">short</span><span style="color: #000000;">&#41;</span> student.周杰倫:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"周杰倫"</span>, <span style="color: #808080;">"明星"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">case</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">short</span><span style="color: #000000;">&#41;</span> student.蔡依林:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"蔡依林"</span>, <span style="color: #808080;">"明星"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">case</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">short</span><span style="color: #000000;">&#41;</span> student.方文山:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"方文山"</span>, <span style="color: #808080;">"明星"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">case</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">short</span><span style="color: #000000;">&#41;</span> student.王立宏:</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"王立宏"</span>, <span style="color: #808080;">"明星"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">break</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">default</span>:</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"所選取數值不在範圍中"</span>,<span style="color: #808080;">"注意"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">break</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><img src="http://farm4.static.flickr.com/3457/3246977289_e5f24e103a_o.png"></img></p>
<p><img src="http://farm4.static.flickr.com/3103/3246977333_71ce6b1b13_o.png"></img></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/184/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>結構 (struct) 資料型別</title>
		<link>http://m955.com/wp/archives/183</link>
		<comments>http://m955.com/wp/archives/183#comments</comments>
		<pubDate>Sat, 31 Jan 2009 17:38:46 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=183</guid>
		<description><![CDATA[struct 是一種用來宣告結構的關鍵字，在結構中包含相關變數，可以將結構視為變數群組，以學生資料 (student) 來說，若要設計其結構，應該包含幾個相關變數，如：學號(num)，姓名(name)、電話(te... ]]></description>
			<content:encoded><![CDATA[<p>struct 是一種用來宣告結構的關鍵字，在結構中包含相關變數，可以將結構視為變數群組，以學生資料 (student) 來說，若要設計其結構，應該包含幾個相關變數，如：學號(num)，姓名(name)、電話(tel)、手機(mobile)、地址(address)等，底下介紹結構的宣告及叫用方式：</p>
<p>結構 (struct) 宣告方式：</p>
<table id="table_code" border="1">
<tr>
<td>
[存取修飾詞] struct [結構名稱]<br />
{<br />
　　[存取修飾詞] [資料型別] [變數名稱];<br />
　　[存取修飾詞] [資料型別] [變數名稱];<br />
　　...<br />
}
  </td>
</tr>
</table>
<p>　</p>
<p>結構 (struct) 叫用方式：</p>
<table id="table_code" border="1">
<tr>
<td>
[結構名稱] [變數名稱];
  </td>
</tr>
</table>
<p>　</p>
<p>語法範例：</p>
<div class="igBar"><span id="lcsharp-14"><a href="#" onclick="javascript:showPlainTxt('csharp-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-14">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">struct</span> Student</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Num;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Name;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Tel;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Mobile;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">public</span> <span style="color: #FF0000;">string</span> Address;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">private</span> <span style="color: #0600FF;">void</span> btnAdd_Click<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">object</span> sender, EventArgs e<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//宣告結構</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Student std;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//指定成員變數</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std.<span style="color: #0000FF;">Num</span> = txtNum.<span style="color: #0000FF;">Text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std.<span style="color: #0000FF;">Name</span> = txtName.<span style="color: #0000FF;">Text</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std.<span style="color: #0000FF;">Tel</span> = txtTel.<span style="color: #0000FF;">Text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std.<span style="color: #0000FF;">Mobile</span> = txtMobile.<span style="color: #0000FF;">Text</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; std.<span style="color: #0000FF;">Address</span> = txtAddress.<span style="color: #0000FF;">Text</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">String</span> msg = <span style="color: #808080;">""</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg = msg + <span style="color: #808080;">"學號："</span> + std.<span style="color: #0000FF;">Num</span> + <span style="color: #808080;">"<span style="color: #008080; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg = msg + <span style="color: #808080;">"姓名："</span> + std.<span style="color: #0000FF;">Name</span> + <span style="color: #808080;">"<span style="color: #008080; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg = msg + <span style="color: #808080;">"電話："</span> + std.<span style="color: #0000FF;">Tel</span> + <span style="color: #808080;">"<span style="color: #008080; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg = msg + <span style="color: #808080;">"手機："</span> + std.<span style="color: #0000FF;">Mobile</span> + <span style="color: #808080;">"<span style="color: #008080; font-weight: bold;">\n</span>"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; msg = msg + <span style="color: #808080;">"地址："</span> + std.<span style="color: #0000FF;">Address</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MessageBox.<span style="color: #0000FF;">Show</span><span style="color: #000000;">&#40;</span>msg, <span style="color: #808080;">"學生基本資料"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p><img src="http://farm4.static.flickr.com/3257/3241098181_89a0bfb401_o.png" alt="" /> </p>
<p><img src="http://farm4.static.flickr.com/3079/3241943046_c7b3fbe888_o.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/183/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>列舉、結構、類別的比較表</title>
		<link>http://m955.com/wp/archives/182</link>
		<comments>http://m955.com/wp/archives/182#comments</comments>
		<pubDate>Sat, 31 Jan 2009 16:12:57 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/?p=182</guid>
		<description><![CDATA[


enum
struct
class


中文意義
列舉
結構
類別


成員資料型別
受限制、而且只能為整數型別
不受限制
不受限制


叫用方法
直接輸入列舉名稱
宣告結構變數
宣告類別變數


使用 static 修飾詞
否
... ]]></description>
			<content:encoded><![CDATA[<table id="table_style" border="1">
<tr>
<td bgcolor="#dddddd"></td>
<td bgcolor="#dddddd">enum</td>
<td bgcolor="#dddddd">struct</td>
<td bgcolor="#dddddd">class</td>
</tr>
<tr>
<td bgcolor="#dddddd">中文意義</td>
<td>列舉</td>
<td>結構</td>
<td>類別</td>
</tr>
<tr>
<td bgcolor="#dddddd">成員資料型別</td>
<td>受限制、而且只能為整數型別</td>
<td>不受限制</td>
<td>不受限制</td>
</tr>
<tr>
<td bgcolor="#dddddd">叫用方法</td>
<td>直接輸入列舉名稱</td>
<td>宣告結構變數</td>
<td>宣告類別變數</td>
</tr>
<tr>
<td bgcolor="#dddddd">使用 static 修飾詞</td>
<td>否</td>
<td>否</td>
<td>可</td>
</tr>
<tr>
<td bgcolor="#dddddd">包含事件及方法</td>
<td>否</td>
<td>可</td>
<td>可</td>
</tr>
<tr>
<td bgcolor="#dddddd">介面實作</td>
<td>否</td>
<td>可</td>
<td>可</td>
</tr>
<tr>
<td bgcolor="#dddddd">結構函式</td>
<td>否</td>
<td>可</td>
<td>可</td>
</tr>
<tr>
<td bgcolor="#dddddd">型別系統</td>
<td>Value Type</td>
<td>Value Type</td>
<td>Reference Type</td>
</tr>
<tr>
<td bgcolor="#dddddd">預設傳遞參數方式</td>
<td>Call by Value</td>
<td>Call by Value</td>
<td>Call by Reference</td>
</tr>
<tr>
<td bgcolor="#dddddd">實體存放記憶體在Stack或Heap</td>
<td>Stack</td>
<td>Stack</td>
<td>Heap</td>
</tr>
<tr>
<td bgcolor="#dddddd">欄位初始設定式</td>
<td>否</td>
<td>否</td>
<td>可</td>
</tr>
<tr>
<td bgcolor="#dddddd">指派成員內容值</td>
<td>可以，只能整數</td>
<td>否</td>
<td>可</td>
</tr>
<tr>
<td bgcolor="#dddddd">功能</td>
<td>簡單</td>
<td>普通</td>
<td>較強</td>
</tr>
</table>
<p>　</p>
<p>結構 (struct) 宣告方式：</p>
<table id="table_code" border="1">
<tr>
<td>
[存取修飾詞] struct [結構名稱]<br />
{<br />
　　[存取修飾詞] [資料型別] [變數名稱];<br />
　　[存取修飾詞] [資料型別] [變數名稱];<br />
　　...<br />
}
  </td>
</tr>
</table>
<p>　</p>
<p>列舉 (enum) 宣告方式：</p>
<table id="table_code" border="1">
<tr>
<td>
[存取修飾詞] enum [列舉名稱] : [資料型別]<br />
{<br />
　　[成員1],<br />
　　[成員2],<br />
　　...<br />
　　[成員n]<br />
}
  </td>
</tr>
</table>
<p>　</p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/182/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# 比較字串</title>
		<link>http://m955.com/wp/archives/174</link>
		<comments>http://m955.com/wp/archives/174#comments</comments>
		<pubDate>Mon, 08 Dec 2008 15:53:40 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/174</guid>
		<description><![CDATA[C# 屬於強型別的資料型態，所以在型別方面，編譯器檢查的很嚴格，所以一些在 VB.NET 中習慣的用法，拿到 C# 中就會出現錯誤。
舉例來說 C# 不能使用 0 或 1 來替代布林值，而字串也不能直接比... ]]></description>
			<content:encoded><![CDATA[<p>C# 屬於強型別的資料型態，所以在型別方面，編譯器檢查的很嚴格，所以一些在 VB.NET 中習慣的用法，拿到 C# 中就會出現錯誤。</p>
<p>舉例來說 C# 不能使用 0 或 1 來替代布林值，而字串也不能直接比較，這對我們剛開始會造成一些困擾！下面 VB.NET 的用法如果拿到 C# 中使用就會出錯</p>
<div class="igBar"><span id="lvbnet-17"><a href="#" onclick="javascript:showPlainTxt('vbnet-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">VB.NET:</span>
<div id="vbnet-17">
<div class="vbnet">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">Dim</span> a <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> = <span style="color: #808080;">"111"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">Dim</span> b <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> = <span style="color: #808080;">"111"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">IF</span> a = b <span style="color: #FF8000;">THEN</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">...</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">END</span> <span style="color: #0600FF;">IF</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p>  </p>
<p>C# 針對比較字串有兩個比較常用的函數：</p>
<p>String.Compare&#160; 比較兩個字串的值。傳回整數值   <br />String.Equals 比較兩個字串的值。傳回布林值</p>
<p>C#中改用比較字串的函數</p>
<div class="igBar"><span id="lcsharp-18"><a href="#" onclick="javascript:showPlainTxt('csharp-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-18">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">String</span> a = <span style="color: #808080;">"111"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">String</span> b = <span style="color: #808080;">"222"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">if</span><span style="color: #000000;">&#40;</span><span style="color: #FF0000;">String</span>.<span style="color: #0000FF;">Equals</span><span style="color: #000000;">&#40;</span>a,b<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ....</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">else</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; ....</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>參考資料：<a href="http://msdn.microsoft.com/zh-tw/library/fbh501kz(VS.80).aspx" target="_blank">C#比較字串(MSDN)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/174/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>C# 陣列的宣告方式</title>
		<link>http://m955.com/wp/archives/165</link>
		<comments>http://m955.com/wp/archives/165#comments</comments>
		<pubDate>Tue, 11 Nov 2008 10:13:27 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/165</guid>
		<description><![CDATA[剛開始接觸 C# ，它的宣告方式跟 C/C++，表面上看起來好像相同，不過仔細一看，卻和我習慣方式不一樣，例如在 VB 裡宣告一個陣列：Dim arr1() As String = { }， 在 C# 裡面卻是這樣宣告的：String[] ar... ]]></description>
			<content:encoded><![CDATA[<p>剛開始接觸 C# ，它的宣告方式跟 C/C++，表面上看起來好像相同，不過仔細一看，卻和我習慣方式不一樣，例如在 VB 裡宣告一個陣列：Dim arr1() As String = { }， 在 C# 裡面卻是這樣宣告的：String[] arr1 = { };，有點不習慣，不過看久了也還好。</p>
<p><span id="more-165"></span></p>
<p>以下是一些陣列的宣告方式：</p>
<div class="igBar"><span id="lcsharp-20"><a href="#" onclick="javascript:showPlainTxt('csharp-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-20">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">namespace</span> ConsoleApplication1</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #FF0000;">class</span> Program</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第1種宣告方式</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arr1 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #FF0000;color:#800000;">5</span><span style="color: #000000;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第2種宣告方式，不指定陣列大小</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arr2 = <a href="http://www.google.com/search?q=new+msdn.microsoft.com" target="_blank"><span style="color: #008000;">new</span></a> <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><span style="color: #808080;">"王家豪"</span>, <span style="color: #808080;">"鄭惠婷"</span>, <span style="color: #808080;">"蔡昱友"</span>, <span style="color: #808080;">"蔡雅芳"</span>, <span style="color: #808080;">"林嬌岳"</span><span style="color: #000000;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//第3種宣告方式，直接指定初值，比較方便</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> arr3 = <span style="color: #000000;">&#123;</span> <span style="color: #808080;">"陳苑星"</span>, <span style="color: #808080;">"陳宏行"</span>, <span style="color: #808080;">"陳麗娟"</span>, <span style="color: #808080;">"趙智和"</span>, <span style="color: #808080;">"白嘉鳳"</span> <span style="color: #000000;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//多維陣列</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span>,<span style="color: #000000;">&#93;</span> arr4 = <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#123;</span> <span style="color: #808080;">"王"</span>, <span style="color: #808080;">"趙"</span>, <span style="color: #808080;">"白"</span> <span style="color: #000000;">&#125;</span>, <span style="color: #000000;">&#123;</span> <span style="color: #808080;">"陳"</span>, <span style="color: #808080;">"蔡"</span>, <span style="color: #808080;">"郭"</span> <span style="color: #000000;">&#125;</span> <span style="color: #000000;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//讀出arr3</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> i = <span style="color: #FF0000;color:#800000;">0</span>; i &lt;<span style="color: #FF0000;color:#800000;">5</span>; i++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>arr3<span style="color: #000000;">&#91;</span>i<span style="color: #000000;">&#93;</span> + <span style="color: #808080;">"<span style="color: #008080; font-weight: bold;">\n</span>"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-style: italic;">//讀出arr4</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> j = <span style="color: #FF0000;color:#800000;">0</span>; j &lt;<span style="color: #FF0000;color:#800000;">2</span>; j++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0600FF;">for</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> n = <span style="color: #FF0000;color:#800000;">0</span>; n &lt;<span style="color: #FF0000;color:#800000;">3</span>; n++<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>arr4<span style="color: #000000;">&#91;</span>j, n<span style="color: #000000;">&#93;</span> + <span style="color: #808080;">"<span style="color: #008080; font-weight: bold;">\n</span>"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">ReadLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/165/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# 簡介</title>
		<link>http://m955.com/wp/archives/164</link>
		<comments>http://m955.com/wp/archives/164#comments</comments>
		<pubDate>Tue, 11 Nov 2008 03:34:56 +0000</pubDate>
		<dc:creator>blue955</dc:creator>
				<category><![CDATA[程式]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://m955.com/wp/archives/164</guid>
		<description><![CDATA[&#160;&#160;&#160;&#160;&#160;&#160; 好吧！我知道我必須踏入這個萬惡的深淵裡，在現今兩大主流 (JAVA、C#) 中尋找最適合我的武器，雖然我很喜歡 VB，但是看在正規的程式設計師眼中，VB 就像是玩具一... ]]></description>
			<content:encoded><![CDATA[<p>&#160;&#160;&#160;&#160;&#160;&#160; 好吧！我知道我必須踏入這個萬惡的深淵裡，在現今兩大主流 (JAVA、C#) 中尋找最適合我的武器，雖然我很喜歡 VB，但是看在正規的程式設計師眼中，VB 就像是玩具一般，尤其上課老師談到 VB 時，眼中流露出的不屑，真是令我感到萬般不自在，真想舉手幹橋他一番，VB 不是原罪，在 DOT.NET 時代中，VB 已經蛻化成完整物件導向語言，加上多執行緒、泛型，其實真的沒什麼好詬病的，VB 不再是玩具，不再是小孩玩泥巴，不過也大大提高了學習的曲線。</p>
<p><span id="more-164"></span></p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 一開始對 C# 的確是沒什麼好感，不過微軟頃全力資源要拱這個語言出線，與 JAVA 抗衡，令人不得不正視它的存在，沒有什麼視窗軟體是 VB 寫不出來的，以上這句話沒錯，不過在現今 NET 時代來臨，跨平台也成為各大廠逐鹿中原的條件之一，手機、LINUX 市場，數位家電、嵌入式平台，成為最大未開發地帶。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 無疑的，在桌面作業系統方面，微軟是最大贏家，其地位在未來幾十年應該還無法撼動，但在其他領域，可就未必了，微軟有認知到這一點，所以提倡出 C# 的雛形，而後有 Inter 及 HP 加入開發，並於 2000 年 10 月將 C# 交由國際標準規範組織，「歐洲電腦廠商協會（ECMA）」審核成為國際標準的程式語言。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; C# 的出發點在於，提供程式設計師，一個像 VB 容易開發，同時又像 C/C++ 強大的程式語言。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; 在開發軟體上面，C# 不一定要選擇 Visual Studio，其實只要配合微軟的 <a href="http://msdn.microsoft.com/en-us/windowsvista/bb980924.aspx" target="_blank">SDK</a>，用記事本也可以撰寫 C#，同時在市面上也有許多的開發套件可供選擇，<a href="http://www.mono-project.com/" target="_blank">MONO</a> 就是其中之一，MONO 有 LINUX 版本，可以提供在 LINUX 底下的 C# 開發環境。</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160; C# 在語法撰寫上，與 C/C++ 類似，可以讓 JAVA、C/C++ 的程式設計師快速上手。</p>
<p><a href=" http://www.microsoft.com/taiwan/vstudio/express/visualcsharp/" target="_blank"><br />
http://www.microsoft.com/taiwan/vstudio/express/visualcsharp/</a></p>
<p>先來個 Hello World 吧！</p>
<div class="igBar"><span id="lcsharp-22"><a href="#" onclick="javascript:showPlainTxt('csharp-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">C#:</span>
<div id="csharp-22">
<div class="csharp">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #0600FF;">using</span> <span style="color: #000000;">System</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #FF0000;">class</span> Program</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #0600FF;">static</span> <span style="color: #0600FF;">void</span> Main<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">string</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> args<span style="color: #000000;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">"Hello World C#"</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; Console.<span style="color: #0000FF;">ReadLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #000000;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://m955.com/wp/archives/164/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

