<?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>腦功仔個Blog &#187; C#</title>
	<atom:link href="http://orz.hk/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://orz.hk</link>
	<description>每天都努力用腦用功的打工仔</description>
	<lastBuildDate>Thu, 01 Dec 2011 03:36:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>如何寫 C# 隊冧台 web server 之 1</title>
		<link>http://orz.hk/2009/10/01/3475/</link>
		<comments>http://orz.hk/2009/10/01/3475/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 16:48:45 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://orz.hk/?p=3475</guid>
		<description><![CDATA[雖然 .NET framework 有好多 design 黎防止個 program 影響台 server, 但係依然有方法隊冧佢, 以下係隊冧一台 Windows 2000 IIS 既方法 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 &#60;% &#160; class StackOverflow &#123; public int OverflowMe &#123; get &#123; return OverflowMe; &#125; &#125; &#125; &#160; StackOverflow overflow = new StackOverflow&#40;&#41;; int i [...]]]></description>
			<content:encoded><![CDATA[<p>雖然 .NET framework 有好多 design 黎防止個 program 影響台 server, 但係依然有方法隊冧佢, 以下係隊冧一台 Windows 2000 IIS 既方法</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">&lt;%</span>
&nbsp;
class StackOverflow
<span style="color: #009900;">&#123;</span>
   public <span style="color: #993333;">int</span> OverflowMe 
   <span style="color: #009900;">&#123;</span>
       get
       <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> OverflowMe<span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
StackOverflow overflow <span style="color: #339933;">=</span> new StackOverflow<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> i <span style="color: #339933;">=</span> overflow.<span style="color: #202020;">OverflowMe</span><span style="color: #339933;">;</span>
<span style="color: #339933;">%&gt;</span></pre></td></tr></table></div>

<p>基本上overflow 唔到都 loop 得死。</p>
<p>至於其他版本既 IIS 影響應該冇咁大, 或者有機會再試試吧</p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2009/10/01/3475/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>今期一本大便講開Facebook古惑仔 Online 竟然有我個blog 既 screen capture</title>
		<link>http://orz.hk/2008/08/01/2333/</link>
		<comments>http://orz.hk/2008/08/01/2333/#comments</comments>
		<pubDate>Fri, 01 Aug 2008 09:23:42 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[古惑仔Online]]></category>

		<guid isPermaLink="false">http://orz.hk/?p=2333</guid>
		<description><![CDATA[一本大便某細小的角落: &#8220;竟然有人特登寫外掛搵錢, 證明隻game超受歡迎. 結果搞到設計程式班人要發聲明, 警告大家一用外掛就會被停止帳號!&#8221;, 主要 screen capture 左我 &#8220;Facebook  古惑仔 Online 寫左自動做任務同存錢機&#8221; 篇野。 傻啦, 外掛邊度禁得到, 尤其是 web-based game。 況且好多外國 web-based game 有成上百隻唔同既外掛任君選擇, 功能同完整性都比起我既優良得多, 只係香港d 記者小見多怪吧。 而且隻 game 並無指明禁外掛止, 似乎係針對惡意攻擊同埋本身既bug 有關, 唔信睇返當時隻 game 既聲明: 各位「古惑仔Online」的玩家，對於之前伺服器於繁忙時間不勝負荷的情況，我們已作出相應改善。現在，系統已能應負繁忙時間的流量。對於少部份因為上次資料出錯而無故出現負錢情況的玩家，可以在我的古惑仔內重設現金。 期間，我們發現少部份玩家嚐試惡意破壞系統。對於嚐試惡意破壞系統的玩家，我們將會停止該玩家在「古惑仔Online」的帳號。請各位玩家自重。 我平時寫既 web-based 外掛並唔係用 javascript over greasemonkey, 而係用 C#, 用 greasemonkey 理論上係有可能 detect 得到 (實際上未試過), 但係用 C# 黎寫就基本上冇可能, 因為可以完全模擬一個真人, 而 [...]]]></description>
			<content:encoded><![CDATA[<p>一本大便某細小的角落:</p>
<blockquote><p>&#8220;竟然有人特登寫外掛搵錢, 證明隻game超受歡迎. 結果搞到設計程式班人要發聲明, 警告大家一用外掛就會被停止帳號!&#8221;, 主要 screen capture 左我 &#8220;Facebook  古惑仔 Online 寫左自動做任務同存錢機&#8221; 篇野。</p></blockquote>
<p>傻啦, 外掛邊度禁得到, 尤其是 web-based game。 況且好多外國 web-based game 有成上百隻唔同既外掛任君選擇, 功能同完整性都比起我既優良得多, 只係香港d 記者小見多怪吧。 而且隻 game 並無指明禁外掛止, 似乎係針對惡意攻擊同埋本身既bug 有關, 唔信睇返當時隻 game 既聲明:</p>
<blockquote><p>各位「古惑仔Online」的玩家，對於之前伺服器於繁忙時間不勝負荷的情況，我們已作出相應改善。現在，系統已能應負繁忙時間的流量。對於少部份因為上次資料出錯而無故出現負錢情況的玩家，可以在我的古惑仔內重設現金。</p>
<p>期間，我們發現少部份玩家嚐試惡意破壞系統。對於嚐試惡意破壞系統的玩家，我們將會停止該玩家在「古惑仔Online」的帳號。請各位玩家自重。</p></blockquote>
<p>我平時寫既 web-based 外掛並唔係用 javascript over greasemonkey, 而係用 C#, 用 greasemonkey 理論上係有可能 detect 得到 (實際上未試過), 但係用 C# 黎寫就基本上冇可能, 因為可以完全模擬一個真人, 而 greasemonkey 就會有 javascript 插入。</p>
<p>況且我寫既外掛並唔係玩 game 咁簡單, 我寫既主要用黎突破圖像驗証, 實行全自動化瀏覽, 而且強就強在部份認字 algorithm 都自己 develop 埋, 哈哈!</p>
<p>而且我個外掛只算係幫人去玩, 唔同其他外掛咁幫人去 cheat。 停人用外掛, 不如搞好d bug 唔好俾人 cheat 好過。</p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2008/08/01/2333/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Accessing different controls inside a GridView control 更新</title>
		<link>http://orz.hk/2008/05/08/2118/</link>
		<comments>http://orz.hk/2008/05/08/2118/#comments</comments>
		<pubDate>Thu, 08 May 2008 12:53:26 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=2118</guid>
		<description><![CDATA[一向用開類似依個既方法: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 protected void Button1_Click&#40;object sender, EventArgs e&#41; &#123; // Iterates through the rows of the GridView control foreach &#40;GridViewRow row in GridView1.Rows&#41; &#123; // Selects [...]]]></description>
			<content:encoded><![CDATA[<p>一向用開類似<a href="http://www.codeproject.com/KB/dotnet/AccessingControlsInsideGr.aspx" target="_blank">依個既方法</a>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">protected <span style="color: #993333;">void</span> Button1_Click<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> EventArgs e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Iterates through the rows of the GridView control</span>
    foreach <span style="color: #009900;">&#40;</span>GridViewRow row in GridView1.<span style="color: #202020;">Rows</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Selects the text from the TextBox</span>
        <span style="color: #666666; font-style: italic;">// which is inside the GridViewRow control</span>
&nbsp;
        string textBoxText <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>TextBox<span style="color: #009900;">&#41;</span>row.<span style="color: #202020;">FindControl</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;TextBox1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #202020;">Text</span><span style="color: #339933;">;</span>
        Response.<span style="color: #202020;">Write</span><span style="color: #009900;">&#40;</span>textBoxText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#91;</span><span style="color: #339933;">/</span>geshi<span style="color: #009900;">&#93;</span>
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>p<span style="color: #339933;">&gt;</span>但而家唔再得<span style="color: #339933;">,</span> 因為個 control 唔再屬於 GridViewRow<span style="color: #339933;">,</span> 就我所見 GridViewRow 之下既 Control 變晒System.<span style="color: #202020;">Web</span>.<span style="color: #202020;">UI</span>.<span style="color: #202020;">WebControls</span>.<span style="color: #202020;">DataControlFieldCell</span><span style="color: #339933;">,</span> 而 FindControl 唔會再 search 入去<span style="color: #339933;">,</span> 結果要再搵深多層<span style="color: #339933;">:&lt;/</span>p<span style="color: #339933;">&gt;</span>
<span style="color: #009900;">&#91;</span>geshi lang<span style="color: #339933;">=</span>C<span style="color: #009900;">&#93;</span>
protected <span style="color: #993333;">void</span> Button1_Click<span style="color: #009900;">&#40;</span>object sender<span style="color: #339933;">,</span> EventArgs e<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #666666; font-style: italic;">// Iterates through the rows of the GridView control</span>
    foreach <span style="color: #009900;">&#40;</span>GridViewRow row in GridView1.<span style="color: #202020;">Rows</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        foreach <span style="color: #009900;">&#40;</span>Control ctrl in row.<span style="color: #202020;">Controls</span><span style="color: #009900;">&#41;</span> 
        <span style="color: #009900;">&#123;</span>
           <span style="color: #666666; font-style: italic;">// Selects the text from the TextBox</span>
           <span style="color: #666666; font-style: italic;">// which is inside the DataControlFieldCell control of a GridViewRow </span>
           string textBoxText <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>TextBox<span style="color: #009900;">&#41;</span>ctrl.<span style="color: #202020;">FindControl</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;TextBox1&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #202020;">Text</span><span style="color: #339933;">;</span>
           Response.<span style="color: #202020;">Write</span><span style="color: #009900;">&#40;</span>textBoxText<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2008/05/08/2118/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>係 Windows 2000 度執行個我寫既 C# .NET 程式完全冇反應</title>
		<link>http://orz.hk/2008/03/03/2028/</link>
		<comments>http://orz.hk/2008/03/03/2028/#comments</comments>
		<pubDate>Mon, 03 Mar 2008 17:44:17 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=2028</guid>
		<description><![CDATA[真係乜反應都冇, 完全唔覺佢執行過, 錯誤訊息又冇, Event log 冇面又冇。原來係個程式要用到一個叫 Microsoft.Data.Odbc.Dll 既檔案, 之但係 Windows 2000 裝 .NET Framework 時係冇裝到, 結果佢搵唔到但係又唔出錯誤訊息, 好似一個暗戀人好耐既人, 見暗戀對象拍拖結婚咁無聲無息退出一樣 (爛 gag)。解決方法當然係俾返個暗戀對像佢, 抄個 .exe 連埋 Microsoft.Data.Odbc.Dll。]]></description>
			<content:encoded><![CDATA[<p>真係乜反應都冇, 完全唔覺佢執行過, 錯誤訊息又冇, Event log 冇面又冇。原來係個程式要用到一個叫 Microsoft.Data.Odbc.Dll 既檔案, 之但係 Windows 2000 裝 .NET Framework 時係冇裝到, 結果佢搵唔到但係又唔出錯誤訊息, 好似一個暗戀人好耐既人, 見暗戀對象拍拖結婚咁無聲無息退出一樣 (爛 gag)。解決方法當然係俾返個暗戀對像佢, 抄個 .exe 連埋 Microsoft.Data.Odbc.Dll。 </p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2008/03/03/2028/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# finally 係唔係所有情況都會行 3</title>
		<link>http://orz.hk/2007/12/11/1901/</link>
		<comments>http://orz.hk/2007/12/11/1901/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 16:18:35 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=1901</guid>
		<description><![CDATA[今次用 Environment.Exit(1), 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 using System; using System.Diagnostics; &#160; namespace Test &#123; class Program &#123; static void Function&#40;&#41; &#123; try &#123; throw new Exception&#40;&#41;; &#125; catch &#40;Exception ex&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>今次用 Environment.Exit(1),</p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">using System<span style="color: #339933;">;</span>
using System.<span style="color: #202020;">Diagnostics</span><span style="color: #339933;">;</span>
&nbsp;
namespace Test
<span style="color: #009900;">&#123;</span>
    class Program
    <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> Function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            try
            <span style="color: #009900;">&#123;</span>
                throw new Exception<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            catch <span style="color: #009900;">&#40;</span>Exception ex<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                Environment.<span style="color: #202020;">Exit</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 咁果 finally 會唔會照 run 呢?</span>
            <span style="color: #009900;">&#125;</span>
            finally
            <span style="color: #009900;">&#123;</span>
                Trace.<span style="color: #202020;">WriteLine</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Finally...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> Main<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            Function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</p>
<p>結果:</p>
<blockquote><p>A first chance exception of type &#8216;System.Exception&#8217; occurred in Test.exe</p>
<p>之後乜都冇</p>
</blockquote>
<p><b>即係唔run</b></p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2007/12/11/1901/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# finally 係唔係所有情況都會行 2</title>
		<link>http://orz.hk/2007/12/11/1902/</link>
		<comments>http://orz.hk/2007/12/11/1902/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 16:13:29 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=1902</guid>
		<description><![CDATA[今次惡d, 用 Process.GetCurrentProcess().Kill(), 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 using System; using System.Diagnostics; &#160; namespace Test &#123; class Program &#123; static void Function&#40;&#41; &#123; try &#123; throw new Exception&#40;&#41;; &#125; catch &#40;Exception [...]]]></description>
			<content:encoded><![CDATA[<p>今次惡d, 用 Process.GetCurrentProcess().Kill(),</p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">using System<span style="color: #339933;">;</span>
using System.<span style="color: #202020;">Diagnostics</span><span style="color: #339933;">;</span>
&nbsp;
namespace Test
<span style="color: #009900;">&#123;</span>
    class Program
    <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> Function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            try
            <span style="color: #009900;">&#123;</span>
                throw new Exception<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            catch <span style="color: #009900;">&#40;</span>Exception ex<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                Process.<span style="color: #202020;">GetCurrentProcess</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #202020;">Kill</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 咁果 finally 會唔會照 run 呢?</span>
            <span style="color: #009900;">&#125;</span>
            finally
            <span style="color: #009900;">&#123;</span>
                Trace.<span style="color: #202020;">WriteLine</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Finally...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> Main<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            Function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</p>
<p>結果:</p>
<blockquote><p>A first chance exception of type &#8216;System.Exception&#8217; occurred in Test.exe</p>
<p>之後乜都冇</p>
</blockquote>
<p><b>即係唔run</b></p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2007/12/11/1902/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# finally 係唔係所有情況都會行 1</title>
		<link>http://orz.hk/2007/12/11/1900/</link>
		<comments>http://orz.hk/2007/12/11/1900/#comments</comments>
		<pubDate>Tue, 11 Dec 2007 15:15:23 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=1900</guid>
		<description><![CDATA[就算我行左 return, 咁 finally 入面會唔會行? 最簡單就係試下, 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 &#160; using System; using System.Diagnostics; &#160; namespace Test &#123; class Program &#123; static void Function&#40;&#41; &#123; try &#123; throw [...]]]></description>
			<content:encoded><![CDATA[<p>就算我行左 return, 咁 finally 入面會唔會行? 最簡單就係試下,</p>
<p>
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">&nbsp;
using System<span style="color: #339933;">;</span>
using System.<span style="color: #202020;">Diagnostics</span><span style="color: #339933;">;</span>
&nbsp;
namespace Test
<span style="color: #009900;">&#123;</span>
    class Program
    <span style="color: #009900;">&#123;</span>
        <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> Function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            try
            <span style="color: #009900;">&#123;</span>
                throw new Exception<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            catch <span style="color: #009900;">&#40;</span>Exception ex<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #b1b100;">return</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// 如果我係 catch 入面 return, 咁果 finally 會唔會照 run 呢?</span>
            <span style="color: #009900;">&#125;</span>
            finally
            <span style="color: #009900;">&#123;</span>
                Trace.<span style="color: #202020;">WriteLine</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span>Finally...<span style="color: #339933;">&amp;</span>quot<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #993333;">static</span> <span style="color: #993333;">void</span> Main<span style="color: #009900;">&#40;</span>string<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            Function<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

</p>
<p>結果:</p>
<blockquote><p>A first chance exception of type &#8216;System.Exception&#8217; occurred in Test.exe<br />Finally&#8230;</p>
</blockquote>
<p><b>即係run</b></p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2007/12/11/1900/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>最快將 webcontrol 轉做 HTML string 來 reuse 的方法</title>
		<link>http://orz.hk/2007/05/29/1702/</link>
		<comments>http://orz.hk/2007/05/29/1702/#comments</comments>
		<pubDate>Tue, 29 May 2007 16:17:40 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=1702</guid>
		<description><![CDATA[1 2 3 4 5 6 string RenderControlToString&#40;Control c&#41; &#123; System.IO.StringWriter s = new System.IO.StringWriter&#40;&#41;; c.RenderControl&#40;new System.Web.UI.Html32TextWriter&#40;s&#41;&#41;; return s.ToString&#40;&#41;; &#125; 完]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">string RenderControlToString<span style="color: #009900;">&#40;</span>Control c<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
   System.<span style="color: #202020;">IO</span>.<span style="color: #202020;">StringWriter</span> s <span style="color: #339933;">=</span> new System.<span style="color: #202020;">IO</span>.<span style="color: #202020;">StringWriter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   c.<span style="color: #202020;">RenderControl</span><span style="color: #009900;">&#40;</span>new System.<span style="color: #202020;">Web</span>.<span style="color: #202020;">UI</span>.<span style="color: #202020;">Html32TextWriter</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #b1b100;">return</span> s.<span style="color: #202020;">ToString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>完</p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2007/05/29/1702/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>自製防止自動填 Form 的圖像</title>
		<link>http://orz.hk/2007/05/24/1699/</link>
		<comments>http://orz.hk/2007/05/24/1699/#comments</comments>
		<pubDate>Thu, 24 May 2007 23:27:00 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=1699</guid>
		<description><![CDATA[用了 C# 寫的一個程序, 能夠產生大量圖像以作防止自動填Form 的 bot。因自己也寫了很多這類 bot, 而且對 OCR 有些少認識, 為了易於閱讀, 所以這些圖像也是算易被一般的 OCR 認出。]]></description>
			<content:encoded><![CDATA[<table border="0">
<tbody>
<tr>
<td valign="top">用了 C# 寫的一個程序, 能夠產生大量圖像以作防止自動填Form 的 bot。因自己也寫了很多這類 bot, 而且對 OCR 有些少認識, 為了易於閱讀, 所以這些圖像也是算易被一般的 OCR 認出。</td>
<td valign="top">
<img src="/uploads/computing/45505606.jpg" /><br />
<img src="/uploads/computing/36220565.jpg" />
</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2007/05/24/1699/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ASP.NET DropDownList Autopostback 應用於 DataGrid 時運作的不可靠</title>
		<link>http://orz.hk/2007/05/15/1690/</link>
		<comments>http://orz.hk/2007/05/15/1690/#comments</comments>
		<pubDate>Tue, 15 May 2007 15:41:54 +0000</pubDate>
		<dc:creator>腦功仔</dc:creator>
				<category><![CDATA[開發心得]]></category>
		<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://test.orz.hk/?p=1690</guid>
		<description><![CDATA[若果你有一個 datagrid, 而入面又有 DropDownList, 若果 SelectedValue 做了DataBinding, 理論上進入 Edit mode 便可修改。不過這樣做會是行麻煩, 每改一個 row 便要進入 Edit mode, 然後選擇新項目, 之後再 Update。雖然可以使用 javascript 免除這個步驟, 但要額外應付 post/get 的參數, 令網頁更難管理。 所以便試試將 GridView 內的 ItemTemplate 加入了 DropDownList, 並設定為 AutoPostBack, 並用 OnSelectedValueChanged 以取得用戶的選項。可惜, 每個 row 於 data binding 時都會引發 OnSelectedValueChanged 的 event, 結果沒有修改的項目也要執行更新一次。 至於解決方法, 下回分解。]]></description>
			<content:encoded><![CDATA[<p>若果你有一個 datagrid, 而入面又有 DropDownList, 若果 SelectedValue 做了DataBinding, 理論上進入 Edit mode 便可修改。不過這樣做會是行麻煩, 每改一個 row 便要進入 Edit mode, 然後選擇新項目, 之後再 Update。雖然可以使用 javascript 免除這個步驟, 但要額外應付 post/get 的參數, 令網頁更難管理。</p>
<p>所以便試試將 GridView 內的 ItemTemplate 加入了 DropDownList, 並設定為 AutoPostBack, 並用 OnSelectedValueChanged 以取得用戶的選項。可惜, 每個 row 於 data binding 時都會引發 OnSelectedValueChanged 的 event, 結果沒有修改的項目也要執行更新一次。</p>
<p>至於解決方法, 下回分解。</p>
]]></content:encoded>
			<wfw:commentRss>http://orz.hk/2007/05/15/1690/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

