<?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>Solomon &#187; C#</title>
	<atom:link href="http://www.ms.oyangudi.com/blog/category/csharp/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ms.oyangudi.com/blog</link>
	<description>from Oyangudi...</description>
	<lastBuildDate>Tue, 18 Oct 2011 02:38:17 +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>Consider using System.IO.Path.Combine() instead of string concatenation</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 17:54:49 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=297</guid>
		<description><![CDATA[http://dotnettipoftheday.org/tips/SystemIOPathCombine.aspx Let&#8217;s review the following code for creating a file path: This code is prone to error. For example, when you set the folder setting, you have to remember to make sure it ends with a slash. To avoid such problems use Path.Combine() method which will ensure that the folder has ending slash:]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Consider using System.IO.Path.Combine() instead of string concatenation" data-url="http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><a href="http://dotnettipoftheday.org/tips/SystemIOPathCombine.aspx" target="_blank">http://dotnettipoftheday.org/tips/SystemIOPathCombine.aspx</a></p>
<p>Let&#8217;s review the following code for creating a file path:</p>
<pre class="brush: csharp; title: ; notranslate">
    public string GetFullPath(string fileName)
    {
        string folder = ConfigurationManager.AppSettings[&quot;MyFolder&quot;];
        return folder + fileName;
    }
</pre>
<p>This code is prone to error. For example, when you set the folder setting, you have to remember to make sure it ends with a slash. To avoid such problems use Path.Combine() method which will ensure that the folder has ending slash:</p>
<pre class="brush: csharp; title: ; notranslate">
    public string GetFullPath(string filename)
    {
        string folder = ConfigurationManager.AppSettings[&quot;MyFolder&quot;];
        return Path.Combine(folder, filename);
    }
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Consider using System.IO.Path.Combine() instead of string concatenation" data-url="http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/consider-using-system-io-path-combine-instead-of-string-concatenation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>?? operator (C#)</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/operator-c/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/operator-c/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 17:48:41 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=291</guid>
		<description><![CDATA[http://dotnettipoftheday.org/tips/double_question_mark_operator_cs.aspx &#160; The ?? operator returns the left-hand operand if it is not null, or else it returns the right operand. For example: The ?? operator also works with reference types:]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/operator-c/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/operator-c/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="?? operator (C#)" data-url="http://www.ms.oyangudi.com/blog/csharp/operator-c/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><a href="http://dotnettipoftheday.org/tips/double_question_mark_operator_cs.aspx" target="_blank">http://dotnettipoftheday.org/tips/double_question_mark_operator_cs.aspx</a></p>
<p>&nbsp;</p>
<p>The <strong>??</strong> operator returns the left-hand operand if it is not null, or else it returns the right operand. For example:</p>
<pre class="brush: csharp; title: ; notranslate">
int? x = null;

...

// y = x, unless x is null, in which case y = -1.

int y = x ?? -1;
</pre>
<p>The <strong>??</strong> operator also works with reference types:</p>
<pre class="brush: csharp; title: ; notranslate">
//message = param, unless param is null
//in which case message = &quot;No message&quot;
string message = param ?? &quot;No message&quot;;
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/operator-c/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/operator-c/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="?? operator (C#)" data-url="http://www.ms.oyangudi.com/blog/csharp/operator-c/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/operator-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Correct event invocation</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 17:25:33 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=280</guid>
		<description><![CDATA[http://dotnettipoftheday.org/tips/correct-event-invocation.aspx Be aware that if there are no subscribers a .NET event will be null. Therefore when raising the event from C# test it for null first. However in multithreaded application the last subscriber can unsubscribe immediately after the null check and before the event is raised. To avoid a null reference exception make a temporary copy of the event.]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Correct event invocation" data-url="http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><a href="http://dotnettipoftheday.org/tips/correct-event-invocation.aspx" target="_blank">http://dotnettipoftheday.org/tips/correct-event-invocation.aspx</a></p>
<p>Be aware that if there are no subscribers a .NET event will be null.  Therefore when raising the event from C# test it for null first.</p>
<pre class="brush: csharp; title: ; notranslate">

    public event EventHandler SelectedNodeChanged;

    protected virtual void OnSelectedNodeChanged(object sender, EventArgs e)
    {
        //Event will be null if there are no subscribers
        if (SelectedNodeChanged != null)
        {
            SelectedNodeChanged(this, e);
        }
    }
</pre>
<p>However in multithreaded application the last subscriber can  unsubscribe immediately after the null check and before the event is  raised. To avoid a null reference exception make a temporary copy of the  event.</p>
<pre class="brush: csharp; title: ; notranslate">

    public event EventHandler SelectedNodeChanged;

    protected virtual void OnSelectedNodeChanged(object sender, EventArgs e)
    {
        //Make a temporary copy of the event to avoid possibility of
        //a race condition if the last subscriber unsubscribes
        //immediately after the null check and before the event is raised.
        EventHandler handler = SelectedNodeChanged;

        //Event will be null if there are no subscribers
        if (handler != null)
        {
            handler(this, e);
        }
    }
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Correct event invocation" data-url="http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/correct-event-invocation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Tips &amp; Tricks</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 08:30:59 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=278</guid>
		<description><![CDATA[http://www.codeproject.com/KB/cs/top10_c__tips_and_tricks.aspx http://www.codeproject.com/Articles/109035/Tips-on-Debugging-Using-DebuggerHidden-attribute.aspx http://www.codeproject.com/KB/aspnet/VisualStudioTipsTricks.aspx http://www.csharptipsandtricks.com/ http://dotnettipoftheday.org/ http://dailydotnettips.com/ &#160;]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="C# Tips &#038; Tricks" data-url="http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<ul>
<li><a href="http://www.codeproject.com/KB/cs/top10_c__tips_and_tricks.aspx" target="_blank">http://www.codeproject.com/KB/cs/top10_c__tips_and_tricks.aspx</a></li>
<li><a href="http://www.codeproject.com/Articles/109035/Tips-on-Debugging-Using-DebuggerHidden-attribute.aspx" target="_blank">http://www.codeproject.com/Articles/109035/Tips-on-Debugging-Using-DebuggerHidden-attribute.aspx</a></li>
<li><a href="http://www.codeproject.com/KB/aspnet/VisualStudioTipsTricks.aspx" target="_blank">http://www.codeproject.com/KB/aspnet/VisualStudioTipsTricks.aspx</a></li>
<li><a href="http://www.csharptipsandtricks.com/" target="_blank">http://www.csharptipsandtricks.com/</a></li>
</ul>
<ul>
<li><a href="http://dotnettipoftheday.org/" target="_blank">http://dotnettipoftheday.org/</a></li>
<li><a href="http://dailydotnettips.com/" target="_blank">http://dailydotnettips.com/</a></li>
</ul>
<p>&nbsp;</p>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="C# Tips &#038; Tricks" data-url="http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/c-tips-tricks/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DateTimePicker &#8211; reset focus</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 03:54:18 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[VB.NET]]></category>
		<category><![CDATA[DatTimePicker reset focus]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/vbnet/datetimepicker-reset-focus/</guid>
		<description><![CDATA[Code Snippet &#8211; C# Code Snippet - VB.NET]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="DateTimePicker &ndash; reset focus" data-url="http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p><strong>Code Snippet &#8211; C#</strong></p>
<pre class="brush: csharp; title: ; notranslate">
        private void dateTimePicker1_Enter(object sender, EventArgs e)
        {
            DateTimePickerFormat fmt = dateTimePicker1.Format;

            dateTimePicker1.Format = DateTimePickerFormat.Long;
            dateTimePicker1.Format = DateTimePickerFormat.Custom;
            dateTimePicker1.Format = fmt;
        }
</pre>
</pre>
<p><strong>Code Snippet - VB.NET</strong></p>
<pre class="brush: vb; title: ; notranslate">

    Private Sub DateTimePicker1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.Enter
        Dim fmt As DateTimePickerFormat = DateTimePicker1.Format

        DateTimePicker1.Format = DateTimePickerFormat.Long
        DateTimePicker1.Format = DateTimePickerFormat.Custom
        DateTimePicker1.Format = fmt
    End Sub
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="DateTimePicker &ndash; reset focus" data-url="http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/datetimepicker-reset-focus/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Inherit DataGridView in Windows Forms</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 17:58:16 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[DataGridView Inheritance]]></category>
		<category><![CDATA[DataGridView Visual Inheritance]]></category>
		<category><![CDATA[DataGridView Windows Forms Inheritance]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=50</guid>
		<description><![CDATA[Create a user control class DataGridViewEx and paste the code snippet given. You can use this control where you want an inherited DataGridView. Download source code &#38; sample: 7z file &#8211; DataGridViewInheritance.7z Zip file &#8211; DataGridViewInheritance.zip Updated file &#8211; DataGridViewInheritance-Updated .NET 4 &#8211; DataGridViewInheritance_NET4]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Inherit DataGridView in Windows Forms" data-url="http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<p>Create a user control class <strong>DataGridViewEx</strong> and paste the code snippet given. You can use this control where you want an inherited DataGridView.</p>
<p><strong>Download source code &amp; sample:</strong></p>
<div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:09ad80b9-f642-4d4c-aeae-f54682d2b923" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>7z file &#8211; <a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/InheritDataGridViewinWindowsForms_89D6/DataGridViewInheritance.7z">DataGridViewInheritance.7z</a></p>
</div>
<div id="scid:fb3a1972-4489-4e52-abe7-25a00bb07fdf:dc1dcf2a-6534-4aa1-9496-06a4730efa1e" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<p>Zip file &#8211; <a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/InheritDataGridViewinWindowsForms_89D6/DataGridViewInheritance.zip">DataGridViewInheritance.zip</a></p>
<p>Updated file &#8211; <a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/2009/09/DataGridViewInheritance-Updated.zip">DataGridViewInheritance-Updated</a></p>
<p>.NET 4 &#8211; <a href="http://www.ms.oyangudi.com/blog/wp-content/uploads/2009/09/DataGridViewInheritance_NET4.zip">DataGridViewInheritance_NET4</a></p>
</div>
<pre class="brush: csharp; title: ; notranslate">

using System;
using System.ComponentModel;
using System.Design;
using System.Drawing;
using System.Windows.Forms;

namespace DataGridViewInheritance
{

    [Designer(typeof(System.Windows.Forms.Design.ControlDesigner))]
    public partial class DataGridViewEx : DataGridView
    {
        public DataGridViewEx()
        {
            InitializeComponent();
        }
    }
}
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Inherit DataGridView in Windows Forms" data-url="http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/inherit-datagridview-in-windows-forms/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Decimal to Byte array (vice versa)</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 04:13:44 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Decimal to Byte array (vice versa)]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=35</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Decimal to Byte array (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<pre class="brush: csharp; title: ; notranslate">

        /// &lt;summary&gt;
        /// Decimal to Bye array
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;dec&quot;&gt;decimal&lt;/param&gt;
        /// &lt;returns&gt;byte array&lt;/returns&gt;
        public static byte[] DecimalToBytes(Decimal dec)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(dec);

                    return stream.ToArray();
                }
            }
        }

        /// &lt;summary&gt;
        /// Byte array to Decimal
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;src&quot;&gt;byte array&lt;/param&gt;
        /// &lt;returns&gt;decimal&lt;/returns&gt;
        public static Decimal BytesToDecimal(byte[] src)
        {
            if (src.Length == 1)
            {
                return Decimal.Parse(((char)src[0]).ToString());
            }

           using (MemoryStream stream = new MemoryStream(src))
           {
               using (BinaryReader reader = new BinaryReader(stream))
               {
                   return reader.ReadDecimal();
               }

           }
        }
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Decimal to Byte array (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/decimal-to-byte-array/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Byte array to String (vice versa)</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 04:03:16 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Byte array to String (vice versa)]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=34</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Byte array to String (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<pre class="brush: csharp; title: ; notranslate">

        /// &lt;summary&gt;
        /// Byte arrary to String
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;bytes&quot;&gt;byte array&lt;/param&gt;
        /// &lt;returns&gt;string&lt;/returns&gt;
        public static string BytesToString(byte[] bytes)
        {
            ASCIIEncoding enc = new System.Text.ASCIIEncoding();

            return enc.GetString(bytes);
        }

        /// &lt;summary&gt;
        /// String to Byte array
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;str&quot;&gt;string&lt;/param&gt;
        /// &lt;returns&gt;byte array&lt;/returns&gt;
        public static byte[] StringToBytes(string str)
        {
            ASCIIEncoding enc = new System.Text.ASCIIEncoding();

            return enc.GetBytes(str);
        }    
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Byte array to String (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/byte-array-to-string-vice-versa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Byte array to Integer (vice versa)</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 03:59:18 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Byte array to Integer (vice versa)]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=33</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Byte array to Integer (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<pre class="brush: csharp; title: ; notranslate">

        /// &lt;summary&gt;
        /// Byte array to Integer
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;bytes&quot;&gt;byte array&lt;/param&gt;
        /// &lt;returns&gt;int&lt;/returns&gt;
        public static int BytesToInt(byte[] bytes)
        {
            return int.Parse(BytesToString(bytes).Trim());
        }

        /// &lt;summary&gt;
        /// Byte array to String
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;bytes&quot;&gt;byte array&lt;/param&gt;
        /// &lt;returns&gt;string&lt;/returns&gt;
        public static string BytesToString(byte[] bytes)
        {
            ASCIIEncoding enc = new System.Text.ASCIIEncoding();

            return enc.GetString(bytes);
        }

        /// &lt;summary&gt;
        /// Integer to Byte array
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;value&quot;&gt;int&lt;/param&gt;
        /// &lt;returns&gt;byte array&lt;/returns&gt;
        public static byte[] IntToBytes(int value)
        {
            ASCIIEncoding enc = new System.Text.ASCIIEncoding();

            return enc.GetBytes(value.ToString());
        }

        /// &lt;summary&gt;
        /// Bytes to Integer
        /// &lt;/summary&gt;
        /// &lt;param name=”src”&gt;&lt;/param&gt;
        /// &lt;returns&gt;&lt;/returns&gt;
        public static int BytesToInt(byte[] src)
        {
             if (src.Length == 1)
                 return (int)src[0];
             else if (src.Length &lt;= 2)
                 return BitConverter.ToInt16(src, 0);

             return BitConverter.ToInt32(src, 0);
         }
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Byte array to Integer (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/byte-array-to-integer-vice-versa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hexadecimal to Integer (vice versa)</title>
		<link>http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/</link>
		<comments>http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/#comments</comments>
		<pubDate>Thu, 26 Feb 2009 03:54:36 +0000</pubDate>
		<dc:creator>Solomon</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Hexadecimal to Integer (vice versa)]]></category>

		<guid isPermaLink="false">http://www.ms.oyangudi.com/blog/?p=32</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Hexadecimal to Integer (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
<pre class="brush: csharp; title: ; notranslate">

        /// &lt;summary&gt;
        /// Hexa decimal to String
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;HexString&quot;&gt;hexa decimal string&lt;/param&gt;
        /// &lt;returns&gt;int&lt;/returns&gt;
        public static int HexToInteger(string HexString)
        {
            return int.Parse(HexString, System.Globalization.NumberStyles.HexNumber);
        }

        /// &lt;summary&gt;
        /// Integer to Hexa decimal string
        /// &lt;/summary&gt;
        /// &lt;param name=&quot;IntValue&quot;&gt;int&lt;/param&gt;
        /// &lt;returns&gt;hexa decimal string&lt;/returns&gt;
        public static string IntegerToHex(int IntValue)
        {
            return IntValue.ToString(&quot;X&quot;);
        }
</pre>
<div class="simplesocialbuttons">
<div class="simplesocialbutton ssb-button-googleplus"><!-- Google Plus One--><g:plusone size="medium" count="true" href="http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/"></g:plusone></div>
<div class="simplesocialbutton ssb-button-fblike"><!-- Facebook like--><div id="fb-root"></div><fb:like href="http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/" send="false" layout="button_count" width="100" show_faces="false" action="like" font=""></fb:like></div>
<div class="simplesocialbutton ssb-buttom-twitter"><!-- Twitter--><a name="twitter_share" data-count="horizontal" href="http://twitter.com/share" data-text="Hexadecimal to Integer (vice versa)" data-url="http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/" class="twitter-share-button" rel="nofollow"></a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.ms.oyangudi.com/blog/csharp/hexadecimal-to-decimal-vice-versa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

