<?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"
	>

<channel>
	<title>9'M</title>
	<atom:link href="http://www.sourcecode.in.th/9M/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.sourcecode.in.th/9M</link>
	<description>นายเอ็ม…บล๊อคโค้ดการเขียนโปรแกรม</description>
	<pubDate>Wed, 16 Dec 2009 09:50:40 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
	<language>en</language>
			<item>
		<title>Base64 Encode/Decode</title>
		<link>http://www.sourcecode.in.th/9M/?p=158</link>
		<comments>http://www.sourcecode.in.th/9M/?p=158#comments</comments>
		<pubDate>Wed, 16 Dec 2009 09:41:40 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=158</guid>
		<description><![CDATA[static public string EncodeTo64(string toEncode)
{
byte[] toEncodeAsBytes
= System.Text.ASCIIEncoding.ASCII.GetBytes(toEncode);
string returnValue
= System.Convert.ToBase64String(toEncodeAsBytes);
return returnValue;
}
static public string DecodeFrom64(string encodedData)
{
byte[] encodedDataAsBytes
= System.Convert.FromBase64String(encodedData);
string returnValue =
System.Text.ASCIIEncoding.ASCII.GetString(encodedDataAsBytes);
return returnValue;
}
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;
string myData = “Here is a string to encode.”;
string myDataEncoded = EncodeTo64(myData);
Console.WriteLine(myDataEncoded);
string myDataUnencoded = DecodeFrom64(myDataEncoded);
Console.WriteLine(myDataUnencoded);
Console.ReadLine();
]]></description>
			<content:encoded><![CDATA[<blockquote><p><span>static</span> <span>public</span> <span>string</span> EncodeTo64(<span>string</span> toEncode)</p>
<p>{</p>
<p><span>byte</span>[] toEncodeAsBytes</p>
<p>= System.Text.<span>ASCIIEncoding</span>.ASCII.GetBytes(toEncode);</p>
<p><span>string</span> returnValue</p>
<p>= System.<span>Convert</span>.ToBase64String(toEncodeAsBytes);</p>
<p><span>return</span> returnValue;</p>
<p>}</p></blockquote>
<blockquote><p><span>static</span> <span>public</span> <span>string</span> DecodeFrom64(<span>string</span> encodedData)</p>
<p>{</p>
<p><span>byte</span>[] encodedDataAsBytes</p>
<p>= System.<span>Convert</span>.FromBase64String(encodedData);</p>
<p><span>string</span> returnValue =</p>
<p>System.Text.<span>ASCIIEncoding</span>.ASCII.GetString(encodedDataAsBytes);</p>
<p><span>return</span> returnValue;</p>
<p>}</p></blockquote>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<blockquote><p><span>string</span> myData = <span>“Here is a string to encode.”</span>;</p>
<p><span>string</span> myDataEncoded = EncodeTo64(myData);</p>
<p><span>Console</span>.WriteLine(myDataEncoded);</p>
<p><span>string</span> myDataUnencoded = DecodeFrom64(myDataEncoded);</p>
<p><span>Console</span>.WriteLine(myDataUnencoded);</p>
<p><span>Console</span>.ReadLine();</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=158</wfw:commentRss>
		</item>
		<item>
		<title>Twitter api sample</title>
		<link>http://www.sourcecode.in.th/9M/?p=155</link>
		<comments>http://www.sourcecode.in.th/9M/?p=155#comments</comments>
		<pubDate>Wed, 09 Dec 2009 09:49:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=155</guid>
		<description><![CDATA[using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Twitterizer.Framework;

namespace TwitterSample
{
    class Program
    {
        static void Main(string[] args)
        {
            if (Twitter.VerifyCredentials("twitter_user", "twitter_password"))
       [...]]]></description>
			<content:encoded><![CDATA[<pre class="code"><span>using </span>System;
<span>using </span>System.Collections.Generic;
<span>using </span>System.Linq;
<span>using </span>System.Text;
<span>using </span>Twitterizer.Framework;

<span>namespace </span>TwitterSample
{
    <span>class </span><span>Program
    </span>{
        <span>static void </span>Main(<span>string</span>[] args)
        {
            <span>if </span>(<span>Twitter</span>.VerifyCredentials(<span>"twitter_user"</span>, <span>"twitter_password"</span>))
            {
                <span>Twitter </span>twitter = <span>new </span><span>Twitter</span>(<span>"twitter_user"</span>, <span>"twitter_password"</span>, <span>"my_app"</span>);

                PrintReplies(twitter);
                PrintFollowers(twitter);
                PrintFriends(twitter);
                PrintDirectMessages(twitter);
                PrintFriendsTimeline(twitter);
                PrintPublicTimeline(twitter);
                PrintUserTimeline(twitter);

                <span>//post a message
                </span>twitter.Status.Update(<span>"Testing 123, Testing"</span>);
            }
            <span>Console</span>.ReadKey();
        }

        <span>public static </span><span>TwitterUser </span>GetUserInfo(<span>Twitter </span>twitter, <span>string </span>userId)
        {
            <span>TwitterUser </span>user = twitter.Status.Show(userId);

            <span>return </span>user;
        }

        <span>public static void </span>PrintReplies(<span>Twitter </span>twitter)
        {
            <span>TwitterStatusCollection </span>col = twitter.Status.Replies();

            <span>Console</span>.WriteLine(<span>"Replies"</span>);

            <span>foreach </span>(<span>TwitterStatus </span>status <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Created:                " </span>+ status.Created);
                <span>Console</span>.WriteLine(<span>"ID:                     " </span>+ status.ID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToStatusID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToUserID);
                <span>Console</span>.WriteLine(<span>"IsFavorited:            " </span>+ status.IsFavorited);
                <span>Console</span>.WriteLine(<span>"IsTruncated:            " </span>+ status.IsTruncated);
                <span>Console</span>.WriteLine(<span>"RecipientID:            " </span>+ status.RecipientID);
                <span>Console</span>.WriteLine(<span>"Source:                 " </span>+ status.Source);
                <span>Console</span>.WriteLine(<span>"Text:                   " </span>+ status.Text);
                <span>Console</span>.WriteLine(<span>"TwitterUser.ScreenName: " </span>+ status.TwitterUser.ScreenName);
            }
        }

        <span>public static void </span>PrintFollowers(<span>Twitter </span>twitter)
        {
            <span>TwitterUserCollection </span>col = twitter.User.Followers();

            <span>Console</span>.WriteLine(<span>"Followers"</span>);

            <span>foreach </span>(<span>TwitterUser </span>user <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Description:       " </span>+ user.Description);
                <span>Console</span>.WriteLine(<span>"Friends_count:     " </span>+ user.Friends_count);
                <span>Console</span>.WriteLine(<span>"ID:                " </span>+ user.ID);
                <span>Console</span>.WriteLine(<span>"IsProtected:       " </span>+ user.IsProtected);
                <span>Console</span>.WriteLine(<span>"Location:          " </span>+ user.Location);
                <span>Console</span>.WriteLine(<span>"NumberOfFollowers: " </span>+ user.NumberOfFollowers);
                <span>Console</span>.WriteLine(<span>"ProfileImageUri:   " </span>+ user.ProfileImageUri);
                <span>Console</span>.WriteLine(<span>"ProfileUri:        " </span>+ user.ProfileUri);
                <span>Console</span>.WriteLine(<span>"ScreenName:        " </span>+ user.ScreenName);
                <span>if </span>(user.Status != <span>null</span>)
                {
                    <span>Console</span>.WriteLine(<span>"Status.Text:       " </span>+ user.Status.Text);
                }
                <span>Console</span>.WriteLine(<span>"TimeZone:          " </span>+ user.TimeZone);
                <span>Console</span>.WriteLine(<span>"UserName:          " </span>+ user.UserName);
            }
        }

        <span>public static void </span>PrintFriends(<span>Twitter </span>twitter)
        {
            <span>TwitterUserCollection </span>col = twitter.User.Friends();

            <span>Console</span>.WriteLine(<span>"Friends"</span>);

            <span>foreach </span>(<span>TwitterUser </span>user <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Description:       " </span>+ user.Description);
                <span>Console</span>.WriteLine(<span>"Friends_count:     " </span>+ user.Friends_count);
                <span>Console</span>.WriteLine(<span>"ID:                " </span>+ user.ID);
                <span>Console</span>.WriteLine(<span>"IsProtected:       " </span>+ user.IsProtected);
                <span>Console</span>.WriteLine(<span>"Location:          " </span>+ user.Location);
                <span>Console</span>.WriteLine(<span>"NumberOfFollowers: " </span>+ user.NumberOfFollowers);
                <span>Console</span>.WriteLine(<span>"ProfileImageUri:   " </span>+ user.ProfileImageUri);
                <span>Console</span>.WriteLine(<span>"ProfileUri:        " </span>+ user.ProfileUri);
                <span>Console</span>.WriteLine(<span>"ScreenName:        " </span>+ user.ScreenName);
                <span>if </span>(user.Status != <span>null</span>)
                {
                    <span>Console</span>.WriteLine(<span>"Status.Text:       " </span>+ user.Status.Text);
                }
                <span>Console</span>.WriteLine(<span>"TimeZone:          " </span>+ user.TimeZone);
                <span>Console</span>.WriteLine(<span>"UserName:          " </span>+ user.UserName);
            }
        }

        <span>public static void </span>PrintDirectMessages(<span>Twitter </span>twitter)
        {
            <span>TwitterStatusCollection </span>col = twitter.DirectMessages.DirectMessages();

            <span>Console</span>.WriteLine(<span>"DirectMessages"</span>);

            <span>foreach </span>(<span>TwitterStatus </span>status <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Created:                " </span>+ status.Created);
                <span>Console</span>.WriteLine(<span>"ID:                     " </span>+ status.ID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToStatusID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToUserID);
                <span>Console</span>.WriteLine(<span>"IsFavorited:            " </span>+ status.IsFavorited);
                <span>Console</span>.WriteLine(<span>"IsTruncated:            " </span>+ status.IsTruncated);
                <span>Console</span>.WriteLine(<span>"RecipientID:            " </span>+ status.RecipientID);
                <span>Console</span>.WriteLine(<span>"Source:                 " </span>+ status.Source);
                <span>Console</span>.WriteLine(<span>"Text:                   " </span>+ status.Text);
                <span>Console</span>.WriteLine(<span>"TwitterUser.ScreenName: " </span>+ status.TwitterUser.ScreenName);
            }
        }

        <span>public static void </span>PrintFriendsTimeline(<span>Twitter </span>twitter)
        {
            <span>TwitterStatusCollection </span>col = twitter.Status.FriendsTimeline();

            <span>Console</span>.WriteLine(<span>"FriendsTimeline"</span>);

            <span>foreach </span>(<span>TwitterStatus </span>status <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Created:                " </span>+ status.Created);
                <span>Console</span>.WriteLine(<span>"ID:                     " </span>+ status.ID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToStatusID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToUserID);
                <span>Console</span>.WriteLine(<span>"IsFavorited:            " </span>+ status.IsFavorited);
                <span>Console</span>.WriteLine(<span>"IsTruncated:            " </span>+ status.IsTruncated);
                <span>Console</span>.WriteLine(<span>"RecipientID:            " </span>+ status.RecipientID);
                <span>Console</span>.WriteLine(<span>"Source:                 " </span>+ status.Source);
                <span>Console</span>.WriteLine(<span>"Text:                   " </span>+ status.Text);
                <span>Console</span>.WriteLine(<span>"TwitterUser.ScreenName: " </span>+ status.TwitterUser.ScreenName);
            }
        }

        <span>public static void </span>PrintPublicTimeline(<span>Twitter </span>twitter)
        {
            <span>TwitterStatusCollection </span>col = twitter.Status.PublicTimeline();

            <span>Console</span>.WriteLine(<span>"PublicTimeline"</span>);

            <span>foreach </span>(<span>TwitterStatus </span>status <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Created:                " </span>+ status.Created);
                <span>Console</span>.WriteLine(<span>"ID:                     " </span>+ status.ID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToStatusID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToUserID);
                <span>Console</span>.WriteLine(<span>"IsFavorited:            " </span>+ status.IsFavorited);
                <span>Console</span>.WriteLine(<span>"IsTruncated:            " </span>+ status.IsTruncated);
                <span>Console</span>.WriteLine(<span>"RecipientID:            " </span>+ status.RecipientID);
                <span>Console</span>.WriteLine(<span>"Source:                 " </span>+ status.Source);
                <span>Console</span>.WriteLine(<span>"Text:                   " </span>+ status.Text);
                <span>Console</span>.WriteLine(<span>"TwitterUser.ScreenName: " </span>+ status.TwitterUser.ScreenName);
            }
        }

        <span>public static void </span>PrintUserTimeline(<span>Twitter </span>twitter)
        {
            <span>TwitterStatusCollection </span>col = twitter.Status.UserTimeline();

            <span>Console</span>.WriteLine(<span>"UserTimeline"</span>);

            <span>foreach </span>(<span>TwitterStatus </span>status <span>in </span>col)
            {
                <span>Console</span>.WriteLine(<span>"------------------------------------------"</span>);
                <span>Console</span>.WriteLine(<span>"Created:                " </span>+ status.Created);
                <span>Console</span>.WriteLine(<span>"ID:                     " </span>+ status.ID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToStatusID);
                <span>Console</span>.WriteLine(<span>"InReplyToStatusID:      " </span>+ status.InReplyToUserID);
                <span>Console</span>.WriteLine(<span>"IsFavorited:            " </span>+ status.IsFavorited);
                <span>Console</span>.WriteLine(<span>"IsTruncated:            " </span>+ status.IsTruncated);
                <span>Console</span>.WriteLine(<span>"RecipientID:            " </span>+ status.RecipientID);
                <span>Console</span>.WriteLine(<span>"Source:                 " </span>+ status.Source);
                <span>Console</span>.WriteLine(<span>"Text:                   " </span>+ status.Text);
                <span>Console</span>.WriteLine(<span>"TwitterUser.ScreenName: " </span>+ status.TwitterUser.ScreenName);
            }
        }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=155</wfw:commentRss>
		</item>
		<item>
		<title>ฟังก์ชั่น หานามสกุลของไฟล์ ด้วยภาษา php</title>
		<link>http://www.sourcecode.in.th/9M/?p=151</link>
		<comments>http://www.sourcecode.in.th/9M/?p=151#comments</comments>
		<pubDate>Tue, 08 Sep 2009 11:22:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=151</guid>
		<description><![CDATA[function findexts ($filename)
{
$filename = strtolower($filename) ;
$exts = split(&#8221;[/\\.]&#8220;, $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts;
}
]]></description>
			<content:encoded><![CDATA[<blockquote><p>function findexts ($filename)<br />
{<br />
$filename = strtolower($filename) ;<br />
$exts = split(&#8221;[/\\.]&#8220;, $filename) ;<br />
$n = count($exts)-1;<br />
$exts = $exts[$n];<br />
return $exts;<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=151</wfw:commentRss>
		</item>
		<item>
		<title>สร้าง class แบบ dynamic</title>
		<link>http://www.sourcecode.in.th/9M/?p=148</link>
		<comments>http://www.sourcecode.in.th/9M/?p=148#comments</comments>
		<pubDate>Wed, 02 Sep 2009 11:42:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=148</guid>
		<description><![CDATA[



using System;  


using System.Diagnostics;  


class Foo { }  


static class Program  


{  


    static void Main()  


    {  


        Type type = typeof(Foo);  


        const int count = 5000000;
        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);


        RunTestWithActivator(type, count);
        GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);


        typeof(Program).GetMethod(&#8220;RunTestWithGenerics&#8221;).  


            MakeGenericMethod(type).Invoke(null, new object[] { count });  


    }  


    public static void RunTestWithActivator(Type type, int count)  


    {  


        Stopwatch watch = Stopwatch.StartNew();  


        for (int i = 0; i &#60; count; i++)  


        {  


            object obj = Activator.CreateInstance(type);  


        }  


        watch.Stop();  


        Console.WriteLine(&#8220;With Activator: {0}&#8221;, watch.ElapsedMilliseconds);  


    }  


    public static void RunTestWithGenerics&#60;T&#62;(int count) where T : new() {  


        Stopwatch watch = Stopwatch.StartNew();  


        for (int i = 0; i &#60; count; i++)  


        {  


            T t = new T();  


        }  


        watch.Stop();  


        Console.WriteLine(&#8220;With generics: {0}&#8221;, watch.ElapsedMilliseconds);  


    }  



} 

]]></description>
			<content:encoded><![CDATA[<blockquote>
<table style="border-top-width: 0px; border-left-width: 0px; margin: 2px 0px; width: 99%; border-bottom: #eee 0px solid; border-collapse: collapse; background-color: #fff; border-right-width: 0px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td><span>using</span><span style="font-size: 11px;"> System;  </span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;"><span>using</span><span style="font-size: 11px;"> System.Diagnostics;  </span></td>
</tr>
<tr>
<td><span>class</span><span style="font-size: 11px;"> Foo { }  </span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;"><span>static</span><span style="font-size: 11px;"> </span><span>class</span><span style="font-size: 11px;"> Program  </span></td>
</tr>
<tr>
<td>{  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">    <span>static</span><span style="font-size: 11px;"> </span><span>void</span><span style="font-size: 11px;"> Main()  </span></td>
</tr>
<tr>
<td>    {  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        Type type = <span>typeof</span><span style="font-size: 11px;">(Foo);  </span></td>
</tr>
<tr>
<td>        <span>const</span><span style="font-size: 11px;"> </span><span>int</span><span style="font-size: 11px;"> count = 5000000;<br />
        <span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">GC</span></span><span style="font-size: x-small;">.Collect(</span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">GC</span></span><span style="font-size: x-small;">.MaxGeneration, </span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">GCCollectionMode</span></span><span style="font-size: x-small;">.Forced);</span></span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        RunTestWithActivator(type, count);<br />
        <span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">GC</span></span><span style="font-size: x-small;">.Collect(</span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">GC</span></span><span style="font-size: x-small;">.MaxGeneration, </span><span style="font-size: x-small; color: #2b91af;"><span style="font-size: x-small; color: #2b91af;">GCCollectionMode</span></span><span style="font-size: x-small;">.Forced);</span></td>
</tr>
<tr>
<td>        <span>typeof</span><span style="font-size: 11px;">(Program).GetMethod(</span><span>&#8220;RunTestWithGenerics&#8221;</span><span style="font-size: 11px;">).  </span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">            MakeGenericMethod(type).Invoke(<span>null</span><span style="font-size: 11px;">, </span><span>new</span><span style="font-size: 11px;"> </span><span>object</span><span style="font-size: 11px;">[] { count });  </span></td>
</tr>
<tr>
<td>    }  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">    <span>public</span><span style="font-size: 11px;"> </span><span>static</span><span style="font-size: 11px;"> </span><span>void</span><span style="font-size: 11px;"> RunTestWithActivator(Type type, </span><span>int</span><span style="font-size: 11px;"> count)  </span></td>
</tr>
<tr>
<td>    {  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        Stopwatch watch = Stopwatch.StartNew();  </td>
</tr>
<tr>
<td>        <span>for</span><span style="font-size: 11px;"> (</span><span>int</span><span style="font-size: 11px;"> i = 0; i &lt; count; i++)  </span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        {  </td>
</tr>
<tr>
<td>            <span>object</span><span style="font-size: 11px;"> obj = Activator.CreateInstance(type);  </span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        }  </td>
</tr>
<tr>
<td>        watch.Stop();  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        Console.WriteLine(<span>&#8220;With Activator: {0}&#8221;</span><span style="font-size: 11px;">, watch.ElapsedMilliseconds);  </span></td>
</tr>
<tr>
<td>    }  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">    <span>public</span><span style="font-size: 11px;"> </span><span>static</span><span style="font-size: 11px;"> </span><span>void</span><span style="font-size: 11px;"> RunTestWithGenerics&lt;T&gt;(</span><span>int</span><span style="font-size: 11px;"> count) where T : </span><span>new</span><span style="font-size: 11px;">() {  </span></td>
</tr>
<tr>
<td>        Stopwatch watch = Stopwatch.StartNew();  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        <span>for</span><span style="font-size: 11px;"> (</span><span>int</span><span style="font-size: 11px;"> i = 0; i &lt; count; i++)  </span></td>
</tr>
<tr>
<td>        {  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">            T t = <span>new</span><span style="font-size: 11px;"> T();  </span></td>
</tr>
<tr>
<td>        }  </td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">        watch.Stop();  </td>
</tr>
<tr>
<td>        Console.WriteLine(<span>&#8220;With generics: {0}&#8221;</span><span style="font-size: 11px;">, watch.ElapsedMilliseconds);  </span></td>
</tr>
<tr>
<td style="background-color: #f7f7f7;">    }  </td>
</tr>
</tbody>
</table>
<td>} </td>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=148</wfw:commentRss>
		</item>
		<item>
		<title>C# อ่านเขียน app.config ของโปรแกรม</title>
		<link>http://www.sourcecode.in.th/9M/?p=144</link>
		<comments>http://www.sourcecode.in.th/9M/?p=144#comments</comments>
		<pubDate>Tue, 25 Aug 2009 10:34:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=144</guid>
		<description><![CDATA[อ่าน
string value = ConfigurationManager.AppSettings["appvalue"]; 
เขียน



System.Configuration.Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);   
config.AppSettings.Settings["appvalue"].Value = &#8220;3&#8243;;        
config.Save(ConfigurationSaveMode.Modified);   
ConfigurationManager.RefreshSection(&#8220;appSettings&#8221;);  

 

]]></description>
			<content:encoded><![CDATA[<p><span><span class="keyword">อ่าน</span></span></p>
<blockquote><p><span><span class="keyword">string</span><span> value = ConfigurationManager.AppSettings[</span><span class="string">"appvalue"</span><span>]; </span></span></p></blockquote>
<p><span><span>เขียน</span></span></p>
<div><span></span></div>
<p><span><span></p>
<blockquote>
<p class="alt"><span><span>System.Configuration.Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);   </span></span></p>
<p class="alt"><span>config.AppSettings.Settings[</span><span class="string">"appvalue"</span><span>].Value = </span><span class="string">&#8220;3&#8243;</span><span>;        </span></p>
<p><span>config.Save(ConfigurationSaveMode.Modified);   </span></p>
<p class="alt"><span>ConfigurationManager.RefreshSection(</span><span class="string">&#8220;appSettings&#8221;</span><span>);  </span></p>
</blockquote>
<p> </p>
<p></span></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=144</wfw:commentRss>
		</item>
		<item>
		<title>แสดง path เต็มของไฟล์บน web server</title>
		<link>http://www.sourcecode.in.th/9M/?p=142</link>
		<comments>http://www.sourcecode.in.th/9M/?p=142#comments</comments>
		<pubDate>Thu, 20 Aug 2009 07:36:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=142</guid>
		<description><![CDATA[เป็นโค้ดสั้นๆ ที่เพิ่งจะค้นพบ
&#60;?php
$fullpath = getcwd();
echo &#8220;Full path is $fullpath&#8221;;
?&#62;
]]></description>
			<content:encoded><![CDATA[<p><span class="phpScriptTag"><strong><span style="color: #ff0000;"><span class="phpOperator"><span style="color: #000000;">เป็นโค้ดสั้นๆ ที่เพิ่งจะค้นพบ</span></span></span></strong></span></p>
<blockquote><p><span class="phpScriptTag"><strong><span style="color: #ff0000;"><span class="phpOperator">&lt;</span><span class="phpOperator">?</span>php</span></strong></span><br />
$fullpath <span class="phpOperator"><span style="color: #0000ff;">=</span></span> <span style="color: #0000ff;"><span class="phpFunction">getcwd</span><span class="phpOperator">(</span><span class="phpOperator">)</span></span><span class="phpText">;</span><span class="htmlText"><br />
echo </span><span class="phpString"><span style="color: #cc0000;">&#8220;Full path is $fullpath&#8221;</span></span><span class="phpText">;</span><br />
<span class="phpScriptTag"><strong><span style="color: #ff0000;"><span class="phpOperator">?</span><span class="phpOperator">&gt;</span></span></strong></span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=142</wfw:commentRss>
		</item>
		<item>
		<title>php แสดงรายการไฟล์ใน directory</title>
		<link>http://www.sourcecode.in.th/9M/?p=136</link>
		<comments>http://www.sourcecode.in.th/9M/?p=136#comments</comments>
		<pubDate>Mon, 02 Mar 2009 01:16:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=136</guid>
		<description><![CDATA[
&#60;html&#62;
&#60;head&#62;
&#60;title&#62;PHP opendir()&#60;/title&#62;
&#60;/head&#62;
&#60;body&#62;
&#60;?
$objOpen = opendir(&#8221;./&#8221;);
while (($file = readdir($objOpen)) !== false)
{
echo &#8220;filename: &#8221; . $file . &#8220;&#60;br /&#62;&#8221;;
}
?&#62;
&#60;/body&#62;
&#60;/html&#62; 

]]></description>
			<content:encoded><![CDATA[<blockquote>
<div class="code"><span class="fontcode"><code><span style="color: #000000;">&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;title&gt;PHP opendir()&lt;/title&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;?<br />
$objOpen = <strong>opendir</strong>(&#8221;./&#8221;);<br />
while (($file = <strong>readdir</strong>($objOpen)) !== false)<br />
{<br />
echo &#8220;filename: &#8221; . $file . &#8220;&lt;br /&gt;&#8221;;<br />
}<br />
?&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</span> </code></span></div>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=136</wfw:commentRss>
		</item>
		<item>
		<title>.NET Compact Framework (PDA) ติดต่อ Mssql</title>
		<link>http://www.sourcecode.in.th/9M/?p=134</link>
		<comments>http://www.sourcecode.in.th/9M/?p=134#comments</comments>
		<pubDate>Fri, 06 Feb 2009 04:17:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[MOBILE]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=134</guid>
		<description><![CDATA[ในการติดต่อกับฐานข้อมูลของ microsoft เอง จะใช้ tools ที่ชื่อว่า Microsoft SQL Server 2005 Mobile Edition Device SDK
download ได้จาก
http://www.microsoft.com/downloads/details.aspx?FamilyID=5bd8abaa-5813-4db3-b23a-24551de2ecc1&#38;displaylang=en
ผมเคยแค่ต่อ db ที่เป็น .sdf บนเครื่อง pda ครับ ยังไม่เคยลอง remote ต่อไปยัง db ที่เป็น ip ท่านใดลองได้แล้ว รบกวนแจ้งวิธีการหน่อยนะครับ
]]></description>
			<content:encoded><![CDATA[<p>ในการติดต่อกับฐานข้อมูลของ microsoft เอง จะใช้ tools ที่ชื่อว่า Microsoft SQL Server 2005 Mobile Edition Device SDK</p>
<p>download ได้จาก</p>
<p><a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=5bd8abaa-5813-4db3-b23a-24551de2ecc1&amp;displaylang=en">http://www.microsoft.com/downloads/details.aspx?FamilyID=5bd8abaa-5813-4db3-b23a-24551de2ecc1&amp;displaylang=en</a></p>
<p>ผมเคยแค่ต่อ db ที่เป็น .sdf บนเครื่อง pda ครับ ยังไม่เคยลอง remote ต่อไปยัง db ที่เป็น ip ท่านใดลองได้แล้ว รบกวนแจ้งวิธีการหน่อยนะครับ</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=134</wfw:commentRss>
		</item>
		<item>
		<title>.NET Compact Framework (PDA) ติดต่อ Mysql</title>
		<link>http://www.sourcecode.in.th/9M/?p=132</link>
		<comments>http://www.sourcecode.in.th/9M/?p=132#comments</comments>
		<pubDate>Thu, 05 Feb 2009 14:59:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[MOBILE]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=132</guid>
		<description><![CDATA[ใช้ connector ที่ Mysql มีมาให้ครับ
http://dev.mysql.com/downloads/connector/net/5.1.html
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;
using System.Configuration;
namespace MySQLCompact
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
lBoxResults.Items.Clear();
MySqlConnection connection = new
MySqlConnection(&#8221;SERVER=MySQL server IP
address;DATABASE=databaseName;UID=user;PASSWORD=password;pooling=false&#8221;);
MySqlCommand command = connection.CreateCommand();
MySqlDataReader Reader;
command.CommandText = &#8220;select * from table1&#8243;;
connection.Open();
Reader = command.ExecuteReader();
while (Reader.Read())
{
string thisrow = &#8220;&#8221;;
for (int i = 0; i &#60; Reader.FieldCount; i++)
thisrow += [...]]]></description>
			<content:encoded><![CDATA[<p>ใช้ connector ที่ Mysql มีมาให้ครับ</p>
<p><a href="http://dev.mysql.com/downloads/connector/net/5.1.html">http://dev.mysql.com/downloads/connector/net/5.1.html</a></p>
<blockquote><p>using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using MySql.Data.MySqlClient;<br />
using System.Configuration;</p>
<p>namespace MySQLCompact<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}</p>
<p>private void button1_Click(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
lBoxResults.Items.Clear();<br />
MySqlConnection connection = new<br />
MySqlConnection(&#8221;SERVER=MySQL server IP<br />
address;DATABASE=databaseName;UID=user;PASSWORD=password;pooling=false&#8221;);<br />
MySqlCommand command = connection.CreateCommand();<br />
MySqlDataReader Reader;<br />
command.CommandText = &#8220;select * from table1&#8243;;<br />
connection.Open();<br />
Reader = command.ExecuteReader();<br />
while (Reader.Read())<br />
{<br />
string thisrow = &#8220;&#8221;;<br />
for (int i = 0; i &lt; Reader.FieldCount; i++)<br />
thisrow += Reader.GetValue(i).ToString() +<br />
lBoxResults.Items.Add(thisrow);<br />
}<br />
connection.Close();<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}<br />
}<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=132</wfw:commentRss>
		</item>
		<item>
		<title>แก้ปัญหาต่อ Mysql ด้วย DBDesigner4 ไม่ได้</title>
		<link>http://www.sourcecode.in.th/9M/?p=127</link>
		<comments>http://www.sourcecode.in.th/9M/?p=127#comments</comments>
		<pubDate>Tue, 03 Feb 2009 10:06:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[OpenSource]]></category>

		<guid isPermaLink="false">http://www.sourcecode.in.th/9M/?p=127</guid>
		<description><![CDATA[ผมได้ทดสอบใช้ DBDesigner4. แต่เกิด Error ในขั้นตอนการติดต่อ MySql
Connection to database failed.
dbExpress Error: Invalid
Username/Password
แก้ไขโดย
&#62;mysql -u root -p
&#62;SET PASSWORD FOR &#8216;root&#8217;@'localhost&#8217; = OLD_PASSWORD(&#8217;r00tp45sw0rd&#8217;);
&#62;UPDATE mysql.user SET Password = OLD_PASSWORD(&#8217;r00tp45sw0rd&#8217;) WHERE Host = &#8216;localhost&#8217; AND User = &#8216;root&#8217;;
&#62;FLUSH PRIVILEGES;
]]></description>
			<content:encoded><![CDATA[<p>ผมได้ทดสอบใช้ DBDesigner4. แต่เกิด Error ในขั้นตอนการติดต่อ MySql</p>
<p><span style="color: #ff0000;">Connection to database failed.</span></p>
<blockquote><p><span style="color: #ff0000;">dbExpress Error: Invalid<br />
Username/Password</span></p></blockquote>
<p>แก้ไขโดย</p>
<p><span style="color: #0000ff;">&gt;mysql -u root -p<br />
&gt;SET PASSWORD FOR &#8216;root&#8217;@'localhost&#8217; = OLD_PASSWORD(&#8217;r00tp45sw0rd&#8217;);<br />
&gt;UPDATE mysql.user SET Password = OLD_PASSWORD(&#8217;r00tp45sw0rd&#8217;) WHERE Host = &#8216;localhost&#8217; AND User = &#8216;root&#8217;;<br />
&gt;FLUSH PRIVILEGES;</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sourcecode.in.th/9M/?feed=rss2&amp;p=127</wfw:commentRss>
		</item>
	</channel>
</rss>
