<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Thinq Development - C#</title>
    <link>http://www.thinqdev.com/</link>
    <description>a blog about Development and Tech stuff by Kristian S. Ravndal</description>
    <language>en-us</language>
    <copyright>Kristian Sølve Ravndal</copyright>
    <lastBuildDate>Wed, 15 Apr 2009 19:34:51 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>kristian.ravndal@gmail.com</managingEditor>
    <webMaster>kristian.ravndal@gmail.com</webMaster>
    <item>
      <trackback:ping>http://www.thinqdev.com/Trackback.aspx?guid=03c97aab-dbb9-47a6-981f-8053e090aef3</trackback:ping>
      <pingback:server>http://www.thinqdev.com/pingback.aspx</pingback:server>
      <pingback:target>http://www.thinqdev.com/PermaLink,guid,03c97aab-dbb9-47a6-981f-8053e090aef3.aspx</pingback:target>
      <dc:creator>Kristian</dc:creator>
      <wfw:comment>http://www.thinqdev.com/CommentView,guid,03c97aab-dbb9-47a6-981f-8053e090aef3.aspx</wfw:comment>
      <wfw:commentRss>http://www.thinqdev.com/SyndicationService.asmx/GetEntryCommentsRss?guid=03c97aab-dbb9-47a6-981f-8053e090aef3</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h1>Finally C# gets optional/default parameters!
</h1>
        <p>
One of the things I missed most, when moving from PHP to C#, was the way PHP let you
pass along default parameters for any function. Now it look like C# 4.0 gets the same
feature. Now I often find myself writing lots of overloaded methods, just because
I want it to be easier to use the methods later on in the project 
</p>
        <p>
So this is how it is done today: 
<br /><img alt="Illustation image" src="http://www.thinqdev.com/content/binary/currentway.png" /></p>
        <p>
However, with the new feature in C#4.0, you can now put default values directly into
the method: 
<br /><img alt="Illustation image" src="http://www.thinqdev.com/content/binary/foofoobar.png" /></p>
        <p>
That little line of code, covers all of the methods I wrote with C#3.5. The only thing
to note, is that when you use similar input types for the parameters, it always used
the first default values it finds. In the next example, using “foo(“s string”, false,10)”
will set b = false, since it’s the first of 2 boolean default values. 
<br /><img alt="Illustation image" src="http://www.thinqdev.com/content/binary/thenewway.png" /></p>
        <img width="0" height="0" src="http://www.thinqdev.com/aggbug.ashx?id=03c97aab-dbb9-47a6-981f-8053e090aef3" />
      </body>
      <title>Finally C# gets optional/default parameters!</title>
      <guid isPermaLink="false">http://www.thinqdev.com/PermaLink,guid,03c97aab-dbb9-47a6-981f-8053e090aef3.aspx</guid>
      <link>http://www.thinqdev.com/2009/04/15/FinallyCGetsOptionaldefaultParameters.aspx</link>
      <pubDate>Wed, 15 Apr 2009 19:34:51 GMT</pubDate>
      <description>&lt;h1&gt;Finally C# gets optional/default parameters!
&lt;/h1&gt;
&lt;p&gt;
One of the things I missed most, when moving from PHP to C#, was the way PHP let you
pass along default parameters for any function. Now it look like C# 4.0 gets the same
feature. Now I often find myself writing lots of overloaded methods, just because
I want it to be easier to use the methods later on in the project 
&lt;p&gt;
So this is how it is done today: 
&lt;br /&gt;
&lt;img alt="Illustation image" src="http://www.thinqdev.com/content/binary/currentway.png"&gt; 
&lt;/p&gt;
&lt;p&gt;
However, with the new feature in C#4.0, you can now put default values directly into
the method: 
&lt;br /&gt;
&lt;img alt="Illustation image" src="http://www.thinqdev.com/content/binary/foofoobar.png"&gt; 
&lt;/p&gt;
&lt;p&gt;
That little line of code, covers all of the methods I wrote with C#3.5. The only thing
to note, is that when you use similar input types for the parameters, it always used
the first default values it finds. In the next example, using “foo(“s string”, false,10)”
will set b = false, since it’s the first of 2 boolean default values. 
&lt;br /&gt;
&lt;img alt="Illustation image" src="http://www.thinqdev.com/content/binary/thenewway.png"&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.thinqdev.com/aggbug.ashx?id=03c97aab-dbb9-47a6-981f-8053e090aef3" /&gt;</description>
      <comments>http://www.thinqdev.com/CommentView,guid,03c97aab-dbb9-47a6-981f-8053e090aef3.aspx</comments>
      <category>C#</category>
      <category>Tips&amp;Tricks</category>
      <category>Visual Studio</category>
    </item>
  </channel>
</rss>