<?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>ASP.Net Blog &#187; C#</title>
	<atom:link href="http://allaboutasp.net/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://allaboutasp.net</link>
	<description>Your .Net Zone</description>
	<lastBuildDate>Mon, 14 Jun 2010 00:58:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Optional Parameters in C#</title>
		<link>http://allaboutasp.net/2010/06/optional-parameters-in-c/</link>
		<comments>http://allaboutasp.net/2010/06/optional-parameters-in-c/#comments</comments>
		<pubDate>Mon, 14 Jun 2010 00:58:08 +0000</pubDate>
		<dc:creator>Ajay Pathak</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[.Net 4.0]]></category>
		<category><![CDATA[Optional Parameters]]></category>

		<guid isPermaLink="false">http://allaboutasp.net/2010/06/optional-parameters-in-c/</guid>
		<description><![CDATA[With the release of .NET 4.0 C# programmers are now able to created methods with optional parameters like VB programmers doing. Optional arguments are widely used in VBA for long time. Although they make life a little bit easier for programmers (you don’t have to repeat default values in your method calls).



Code Snippet


using System;
using System.Collections.Generic;
using [...]]]></description>
			<content:encoded><![CDATA[<p>With the release of .NET 4.0 C# programmers are now able to created methods with optional parameters like VB programmers doing. Optional arguments are widely used in VBA for long time. Although they make life a little bit easier for programmers (you don’t have to repeat default values in your method calls).</p>
<p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:03a0a795-8a06-4ad5-b165-b28bba7792c1" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 300px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="color:#0000ff">using</span> System;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">using</span> System.Collections.Generic;</li>
<li><span style="color:#0000ff">using</span> System.Linq;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">using</span> System.Text;</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">namespace</span> optionalParameters</li>
<li>{</li>
<li style="background: #f3f3f3">    <span style="color:#0000ff">class</span> <span style="color:#2b91af">Program</span></li>
<li>    {</li>
<li style="background: #f3f3f3">        <span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> Main(<span style="color:#0000ff">string</span>[] args)</li>
<li>        {</li>
<li style="background: #f3f3f3">            <span style="color:#2b91af">OptionalParameterTest</span> t = <span style="color:#0000ff">new</span> <span style="color:#2b91af">OptionalParameterTest</span>();</li>
<li>            <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Optional Parameter :  {0}&quot;</span>, t.OptionalParameter(<span style="color:#a31515">&quot;One&quot;</span>));</li>
<li style="background: #f3f3f3">            <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Optional Parameter :  {0} &quot;</span>, t.OptionalParameter(<span style="color:#a31515">&quot;One1&quot;</span>, <span style="color:#a31515">&quot;Two1&quot;</span>));</li>
<li>            <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Optional Parameter :  {0} &quot;</span>, t.OptionalParameter(<span style="color:#a31515">&quot;One1&quot;</span>, <span style="color:#a31515">&quot;Two1&quot;</span>,<span style="color:#a31515">&quot;three1&quot;</span>));</li>
<li style="background: #f3f3f3">            <span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Optional Parameter :  {0} &quot;</span>, t.OptionalParameter(<span style="color:#a31515">&quot;One1&quot;</span>, <span style="color:#a31515">&quot;Two1&quot;</span>,<span style="color:#a31515">&quot;Three1&quot;</span>,<span style="color:#a31515">&quot;Four1&quot;</span>));</li>
<li>            <span style="color:#2b91af">Console</span>.ReadLine();</li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>        }</li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>    }</li>
<li style="background: #f3f3f3">    <span style="color:#0000ff">public</span> <span style="color:#0000ff">class</span> <span style="color:#2b91af">OptionalParameterTest</span></li>
<li>    {</li>
<li style="background: #f3f3f3">        <span style="color:#0000ff">public</span> <span style="color:#0000ff">string</span> OptionalParameter(<span style="color:#0000ff">string</span>  one, <span style="color:#0000ff">string</span> two = <span style="color:#a31515">&quot;Two&quot;</span>,<span style="color:#0000ff">string</span> three=<span style="color:#a31515">&quot;Three&quot;</span>,<span style="color:#0000ff">string</span> four=<span style="color:#a31515">&quot;Four&quot;</span>)</li>
<li>        {</li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>           </li>
<li style="background: #f3f3f3">            <span style="color:#0000ff">return</span> one + <span style="color:#a31515">&quot;  &quot;</span> + two + <span style="color:#a31515">&quot;  &quot;</span> + three + <span style="color:#a31515">&quot;  &quot;</span> + four;</li>
<li>        }</li>
<li style="background: #f3f3f3">    }</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3">}</li>
</ol></div>
</p></div>
</p></div>
</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Optional Parameters" border="0" alt="Optional Parameters" src="http://allaboutasp.net/wp-content/uploads/2010/06/OptionalParameters.png" width="525" height="103" /></p>
]]></content:encoded>
			<wfw:commentRss>http://allaboutasp.net/2010/06/optional-parameters-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Understanding Method Overloading in C#</title>
		<link>http://allaboutasp.net/2009/12/understanding-method-overloading-in-c/</link>
		<comments>http://allaboutasp.net/2009/12/understanding-method-overloading-in-c/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 02:30:18 +0000</pubDate>
		<dc:creator>Ajay Pathak</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Method Overloading]]></category>

		<guid isPermaLink="false">http://allaboutasp.net/2009/12/understanding-method-overloading-in-c/</guid>
		<description><![CDATA[Like other Programming languages C# also supports method overloading. Method overloading is a feature found in various programming languages such as Ada, C#, C++, D and Java that allows the creation of several methods with the same name which differ from each other in terms of the type of the input and the type of [...]]]></description>
			<content:encoded><![CDATA[<p>Like other Programming languages C# also supports method overloading. Method overloading is a feature found in various programming languages such as Ada, C#, C++, D and Java that allows the creation of several methods with the same name which differ from each other in terms of the type of the input and the type of the output of the function. [According to <a href="http://en.wikipedia.org/wiki/Method_overloading" target="_blank">wikipedia</a>]</p>
<h2>Method Overloading Example </h2>
<p>Suppose in our application we want to add to two integers, double, float and long. The first way is to create unique methods for each addition operation or call a single method name with distinct set of arguments. </p>
<p>The Visual Studio IDE will provide you assistance while calling overloaded method.</p>
<p><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="method overloading" border="0" alt="method overloading" src="http://allaboutasp.net/wp-content/uploads/2009/12/methodoverloading.png" width="525" height="127" /> </p>
</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:922a0a7a-e813-4b98-a97c-d4e6e8a921ab" class="wlWriterEditableSmartContent">
<div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt">
<div style="background: #000080; color: #fff; font-family: Verdana, Tahoma, Arial, sans-serif; font-weight: bold; padding: 2px 5px">Code Snippet</div>
<div style="background: #ddd; max-height: 500px; overflow: auto">
<ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;">
<li><span style="color:#0000ff">using</span> System;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">using</span> System.Collections.Generic;</li>
<li><span style="color:#0000ff">using</span> System.Linq;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">using</span> System.Text;</li>
<li>&nbsp;</li>
<li style="background: #f3f3f3"><span style="color:#0000ff">namespace</span> Method_Overloading</li>
<li>{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;<span style="color:#0000ff">class</span> <span style="color:#2b91af">Program</span></li>
<li>&#160;&#160;&#160;&#160;{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">static</span> <span style="color:#0000ff">void</span> Main(<span style="color:#0000ff">string</span>[] args)</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;**********************************Method Overloading Demo**********************************&quot;</span>);</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Add two int :&quot;</span> + Add(<span style="color:#a52a2a">1</span>, <span style="color:#a52a2a">1</span>));</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Add two Double :&quot;</span> + Add(<span style="color:#a52a2a">1.0</span>, <span style="color:#a52a2a">1.0</span>));</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Add two float :&quot;</span> + Add(<span style="color:#a52a2a">11.12</span>, <span style="color:#a52a2a">1.123</span>));</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#2b91af">Console</span>.WriteLine(<span style="color:#a31515">&quot;Add two long :&quot;</span> + Add(<span style="color:#a52a2a">234561</span>, <span style="color:#a52a2a">11235678</span>));</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#2b91af">Console</span>.ReadLine();</li>
<li style="background: #f3f3f3">&nbsp;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span>&#160;&#160;<span style="color:#2b91af">Int64</span> Add(<span style="color:#0000ff">int</span> num1, <span style="color:#0000ff">int</span> num2)</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">return</span> num1 + num2;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">double</span> Add(<span style="color:#0000ff">double</span> num1, <span style="color:#0000ff">double</span> num2)</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">return</span> num1 + num2;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">float</span> Add(<span style="color:#0000ff">float</span> num1, <span style="color:#0000ff">float</span> num2)</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">return</span> num1 + num2;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">private</span> <span style="color:#0000ff">static</span> <span style="color:#0000ff">long</span> Add(<span style="color:#0000ff">long</span> num1, <span style="color:#0000ff">long</span> num2)</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;{</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;<span style="color:#0000ff">return</span> num1 + num2;</li>
<li>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;}</li>
<li style="background: #f3f3f3">&#160;&#160;&#160;&#160;}</li>
<li>}</li>
</ol></div>
</p></div>
</p></div>
</p>
<p>Method overloading does not depends upon the return type of method, if you are having two methods with unique name with equal number of arguments and of same type with different return type than these methods are not overloaded method instead they are same methods and compiler will give error at compile time.</p>
<p><a href="http://allaboutasp.net/wp-content/uploads/2009/12/methodoverloadingerror.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="method overloading error" border="0" alt="method overloading error" src="http://allaboutasp.net/wp-content/uploads/2009/12/methodoverloadingerror_thumb.png" width="537" height="91" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://allaboutasp.net/2009/12/understanding-method-overloading-in-c/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
