<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" 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:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>C# 4.0</title>
        <link>http://geekswithblogs.net/michelotti/category/9500.aspx</link>
        <description>C# 4.0</description>
        <language>en-US</language>
        <copyright>Steve Michelotti</copyright>
        <managingEditor>steve.michelotti@gmail.com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>CMAP C# 4.0 Presentation &amp;ndash; Code Samples</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/11/04/cmap-c-4.0-presentation-ndash-code-samples.aspx</link>
            <description>&lt;p&gt;Thanks to everyone who attended my C# 4.0 New Languages Features presentation at CMAP last night.  Both the code and PowerPoint are available for download.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=michelotti&amp;amp;DownloadId=7433" target="_blank"&gt;C# 4.0 New Language Features Download&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;After the presentation, I had a few people ask me about some of tools I was using.  They can all be found on my &lt;a href="http://geekswithblogs.net/michelotti/archive/2008/11/23/developer-tools-and-utilities.aspx" target="_blank"&gt;Developer Tools and Utilities&lt;/a&gt; page. To create my snippets, I’ve been using a tool called Snippy for years (link included on Developer Tools page).  However, lately I’ve also been using &lt;a href="http://www.codeplex.com/SnippetDesigner" target="_blank"&gt;Snippet Designer&lt;/a&gt; which is a Visual Studio add-in that is also quite good.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135992"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135992" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/135992.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/11/04/cmap-c-4.0-presentation-ndash-code-samples.aspx</guid>
            <pubDate>Wed, 04 Nov 2009 18:02:57 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/135992.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/11/04/cmap-c-4.0-presentation-ndash-code-samples.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/135992.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/135992.aspx</trackback:ping>
        </item>
        <item>
            <title>CMAP Presentations this week</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/11/01/cmap-presentations-this-week.aspx</link>
            <description>&lt;p&gt;I’ll be giving a presentation on C# 4.0 New Language Features this Tuesday at the &lt;a href="http://www.cmap-online.org/Meetings/Details/2009-11-03.aspx" target="_blank"&gt;CMAP Main Meeting&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Also I’ll be presenting MVC in the Real World this Saturday at &lt;a href="http://www.cmap-online.org/CodeCamp/" target="_blank"&gt;CMAP Code Camp&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Hope to see you there!&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135938"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135938" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/135938.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/11/01/cmap-presentations-this-week.aspx</guid>
            <pubDate>Mon, 02 Nov 2009 01:22:33 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/135938.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/11/01/cmap-presentations-this-week.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/135938.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/135938.aspx</trackback:ping>
        </item>
        <item>
            <title>Richmond Code Camp - Code Samples</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/10/04/richmond-code-camp---code-samples.aspx</link>
            <description>&lt;p&gt;Thanks to everyone who attended my sessions yesterday at Richmond Code Camp.  Both the code and PowerPoint slides are available for download.&lt;/p&gt;  &lt;p&gt;Download samples for: &lt;a href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=michelotti&amp;amp;ReleaseId=3288" target="_blank"&gt;MVC in the Real World&lt;/a&gt;. Check out the readme.txt file in Solution Items and all SQL scripts for creating the databases.&lt;/p&gt;  &lt;p&gt;Download samples for: &lt;a href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=michelotti&amp;amp;ReleaseId=3289" target="_blank"&gt;C# 4.0 New Language Features&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I had several questions about some of the tools I was using during the presentations (all of which are free).  For the zooming and highlighting, I was using a tool called ZoomIt. For the code snippets, I was just utilizing the built-in code snippets functionality of Visual Studio – however, I use a tool called Snippy to create all of my custom snippets. You can find links to those tools and many other tools I use on my &lt;a href="http://geekswithblogs.net/michelotti/archive/2008/11/23/developer-tools-and-utilities.aspx" target="_blank"&gt;Developer Tools and Utilities&lt;/a&gt; post.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135292"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=135292" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/135292.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/10/04/richmond-code-camp---code-samples.aspx</guid>
            <pubDate>Sun, 04 Oct 2009 20:11:26 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/135292.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/10/04/richmond-code-camp---code-samples.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/135292.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/135292.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 3.0 Deep Dish with a slice of C# 4.0 &amp;ndash; Code Samples</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/08/26/c-3.0-deep-dish-with-a-slice-of-c-4.0-again.aspx</link>
            <description>&lt;p&gt;Thanks to everyone who attended my presentation last night at &lt;a href="http://caparea.net/" target="_blank"&gt;CapArea&lt;/a&gt; on C# 3.0 and C# 4.0.  You can download the C# 3.0 code samples, C# 4.0 code samples, and the PowerPoint presentation from &lt;a href="https://code.msdn.microsoft.com/Release/ProjectReleases.aspx?ProjectName=michelotti&amp;amp;ReleaseId=3148" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Several people asked me about some of the tools I was using during the presentation.  A list of the tools that I use (and more) can be found &lt;a href="http://geekswithblogs.net/michelotti/archive/2008/11/23/developer-tools-and-utilities.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Feel free to email me with any questions.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=134337"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=134337" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/134337.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/08/26/c-3.0-deep-dish-with-a-slice-of-c-4.0-again.aspx</guid>
            <pubDate>Wed, 26 Aug 2009 14:04:51 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/134337.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/08/26/c-3.0-deep-dish-with-a-slice-of-c-4.0-again.aspx#feedback</comments>
            <slash:comments>2</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/134337.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/134337.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 3.0 Deep Dish with a slice of C# 4.0</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/08/23/c-3.0-deep-dish-with-a-slice-of-c-4.0.aspx</link>
            <description>&lt;p&gt;On Tuesday night (August 25), I will be presenting “C# 3.0 Deep Dish with a slice of C# 4.0” at &lt;a href="http://caparea.net/" target="_blank"&gt;CapArea .NET User Group&lt;/a&gt; (but I have to give &lt;a href="http://www.softinsight.com/bnoyes/" target="_blank"&gt;Brian Noyes&lt;/a&gt; credit for the catchy title). The primary content of the presentation will be a deep dive into the C# 3.0 language features. The latter part of the presentation will be an overview of the features coming in C# 4.0. Hope to see you there.&lt;/p&gt;  &lt;p&gt;Additionally, the next night (Wednesday, August 26), I’ll be at &lt;a href="http://www.frednug.org/" target="_blank"&gt;FredNUG&lt;/a&gt; presenting Linq to SQL.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=134266"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=134266" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/134266.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/08/23/c-3.0-deep-dish-with-a-slice-of-c-4.0.aspx</guid>
            <pubDate>Sun, 23 Aug 2009 11:44:45 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/134266.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/08/23/c-3.0-deep-dish-with-a-slice-of-c-4.0.aspx#feedback</comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/134266.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/134266.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 4.0 dynamic keyword with IronRuby</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/08/05/c-4.0-dynamic-keyword-with-ironruby.aspx</link>
            <description>&lt;p&gt;In my continued exploration of C# 4.0, I wanted to put together a simple example of using the C# 4.0 “dynamic” keyword in conjunction with &lt;a href="http://www.ironruby.net/" target="_blank"&gt;IronRuby&lt;/a&gt;.  I’ve been shocked at how difficult it was to find code samples on the internet that actually do this.  With much persistence (and some significant pointing in the right direction from &lt;a href="http://www.codethinked.com/" target="_blank"&gt;Justin Etheredge&lt;/a&gt;) I got my simple example working.  Given that there aren’t many great examples of calling IronRuby from C# 4.0 out there, I figured I better post the code.&lt;/p&gt;  &lt;p&gt;First off, you need to get the *correct* version of &lt;a href="http://ironruby.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27606" target="_blank"&gt;IronRuby that will work with VS2010 Beta 1&lt;/a&gt;.  Next, you want to add the following references to your project (all found in the “bin” folder of the IronRuby download):&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;IronRuby.dll &lt;/li&gt;    &lt;li&gt;IronRuby.Libraries.dll &lt;/li&gt;    &lt;li&gt;Microsoft.Scripting.dll &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Next, create an IronRuby file called “person.rb” that has the following code:&lt;/p&gt; &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; Person&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;    def say_hello&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        puts &lt;span class="str"&gt;"Hello world!"&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    end&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;end&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Finally, here is the C# code:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;ScriptRuntime runtime = IronRuby.Ruby.CreateRuntime();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;ScriptScope scope = runtime.ExecuteFile(&lt;span class="str"&gt;"person.rb"&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;dynamic person = scope.Engine.Execute(&lt;span class="str"&gt;"p = Person.new"&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;person.say_hello();&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Notice the use of the “dynamic” keyword on line 3.  While a full discussion of the dynamic keyword is beyond the scope of this blog post, this keyword is the basis for the dynamic features of C# 4.0 that will be running on top of the Dynamic Language Runtime (DLR) of .NET 4.0.  It will provide a unified way to interact with all things dynamic.  These include:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Dynamic languages like IronRuby, IronPython, and JavaScript &lt;/li&gt;

  &lt;li&gt;Simplified .NET Reflection &lt;/li&gt;

  &lt;li&gt;COM Interop &lt;/li&gt;

  &lt;li&gt;DOM objects like HMTL and XML &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ll be speaking at &lt;a href="http://www.caparea.net" target="_blank"&gt;CapArea&lt;/a&gt; at the end of this month where the last portion of my talk will be dedicated to C# 4.0 new language features.  Additionally, I’ll be devoting an entire talk to C# 4.0 at &lt;a href="http://www.cmap-online.org/" target="_blank"&gt;CMAP&lt;/a&gt; in November.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=133932"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=133932" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/133932.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/08/05/c-4.0-dynamic-keyword-with-ironruby.aspx</guid>
            <pubDate>Wed, 05 Aug 2009 18:51:22 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/133932.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/08/05/c-4.0-dynamic-keyword-with-ironruby.aspx#feedback</comments>
            <slash:comments>1</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/133932.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/133932.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 4.0 Optional Parameters</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/02/05/c-4.0-optional-parameters.aspx</link>
            <description>&lt;p&gt;One of the new language features coming in C# 4.0 is Optional Parameters. In large part, this is due to Microsoft’s plan of co-evolution with C# and VB.NET since VB.NET has had this feature for a while.  Personally, I’m still somewhat undecided about this feature and there has been much written about method overloads versus optional parameters. For example, &lt;a href="http://msdn.microsoft.com/en-us/library/e18yd02w.aspx" target="_blank"&gt;Considerations in Overloading Procedures&lt;/a&gt;.  Ultimately, I do think there will be some scenarios where this will be useful to make code more concise.&lt;/p&gt;  &lt;p&gt;Consider a standard scenario with method overloading or constructor chaining.  In C# we’d have several methods with different signatures where, in effect, we’re really just after default values. Let’s take the scenario where we’ve got a little helper class to send emails in our application. In some cases we want to CC the administrator to troubleshoot issues; in some cases we want rich HTML emails rather than plain text. We might set up our methods like this:&lt;/p&gt; &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(&lt;span class="kwrd"&gt;string&lt;/span&gt; toAddress, &lt;span class="kwrd"&gt;string&lt;/span&gt; bodyText)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;this&lt;/span&gt;.SendMail(toAddress, bodyText, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(&lt;span class="kwrd"&gt;string&lt;/span&gt; toAddress, &lt;span class="kwrd"&gt;string&lt;/span&gt; bodyText, &lt;span class="kwrd"&gt;bool&lt;/span&gt; ccAdministrator)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    &lt;span class="kwrd"&gt;this&lt;/span&gt;.SendMail(toAddress, bodyText, ccAdministrator, &lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(&lt;span class="kwrd"&gt;string&lt;/span&gt; toAddress, &lt;span class="kwrd"&gt;string&lt;/span&gt; bodyText, &lt;span class="kwrd"&gt;bool&lt;/span&gt; ccAdministrator, &lt;span class="kwrd"&gt;bool&lt;/span&gt; isBodyHtml)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    &lt;span class="rem"&gt;// Full implementation here&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This is pretty standard method overloading and we essentially are setting default values (true for CC the Admin, and false for HTML emails). With C# 4.0 we can now make the code more concise by only having to implement 1 method:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(&lt;span class="kwrd"&gt;string&lt;/span&gt; toAddress, &lt;span class="kwrd"&gt;string&lt;/span&gt; bodyText, &lt;span class="kwrd"&gt;bool&lt;/span&gt; ccAdministrator = &lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;bool&lt;/span&gt; isBodyHtml = &lt;span class="kwrd"&gt;false&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="rem"&gt;// Full implementation here&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;However, you do have to take into account your scenario.  If you have a situation where you actually need to know if the consuming code provided a value then this isn’t a good option because if “true” comes in for the 3rd parameter, you don’t know if the consuming code actually set this explicitly or if it was simply the result of the default value.  But in typical scenarios like this, it’s not a big deal.  Cracking open Reflector and looking at the IL that the C# compiler is generating:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;.method &lt;span class="kwrd"&gt;public&lt;/span&gt; hidebysig instance &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(&lt;span class="kwrd"&gt;string&lt;/span&gt; toAddress, &lt;span class="kwrd"&gt;string&lt;/span&gt; bodyText, [opt] &lt;span class="kwrd"&gt;bool&lt;/span&gt; ccAdministrator, [opt] &lt;span class="kwrd"&gt;bool&lt;/span&gt; isBodyHtml) cil managed&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    .param [3] = &lt;span class="kwrd"&gt;bool&lt;/span&gt;(&lt;span class="kwrd"&gt;true&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    .param [4] = &lt;span class="kwrd"&gt;bool&lt;/span&gt;(&lt;span class="kwrd"&gt;false&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    .maxstack 8&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    L_0000: nop &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    L_0001: ret &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Which Reflectors translates to a C# equivalent of:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; SendMail(&lt;span class="kwrd"&gt;string&lt;/span&gt; toAddress, &lt;span class="kwrd"&gt;string&lt;/span&gt; bodyText, [Optional, DefaultParameterValue(&lt;span class="kwrd"&gt;true&lt;/span&gt;)] &lt;span class="kwrd"&gt;bool&lt;/span&gt; ccAdministrator, [Optional, DefaultParameterValue(&lt;span class="kwrd"&gt;false&lt;/span&gt;)] &lt;span class="kwrd"&gt;bool&lt;/span&gt; isBodyHtml)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So if consuming code is written using the least specified “overload” like this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;email.SendMail(&lt;span class="str"&gt;"bob@foo.com"&lt;/span&gt;, &lt;span class="str"&gt;"Hello World"&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;The IL that the C# compiler will generate will actually be the equivalent of this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;email.SendMail(&lt;span class="str"&gt;"bob@foo.com"&lt;/span&gt;, &lt;span class="str"&gt;"Hello World"&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;What’s more interesting is that, unlike traditional method overloading, you have the ability to omit only the 3rd parameter in conjunction with the new &lt;a href="http://geekswithblogs.net/michelotti/archive/2009/01/22/c-4.0-named-parameters-for-better-code-quality.aspx" target="_blank"&gt;Named Parameters&lt;/a&gt; language feature and write your code like this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;email.SendMail(&lt;span class="str"&gt;"bob@foo.com"&lt;/span&gt;, &lt;span class="str"&gt;"Hello World"&lt;/span&gt;, isBodyHtml: &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This will allow consuming code to only pass 3 arguments for succinctness but still invoke the appropriate overload since the IL generated in that instance will be equivalent to this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;email.SendMail(&lt;span class="str"&gt;"bob@foo.com"&lt;/span&gt;, &lt;span class="str"&gt;"Hello World"&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Overall, it’s by no means an earth shattering feature that is being added to the language in stand-alone scenarios (though it will be have a *much* bigger impact in COM Interop).  Used in the correct scenarios, it can improve your code.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129237"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129237" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/129237.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/02/05/c-4.0-optional-parameters.aspx</guid>
            <pubDate>Fri, 06 Feb 2009 03:41:51 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/129237.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/02/05/c-4.0-optional-parameters.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/129237.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/129237.aspx</trackback:ping>
        </item>
        <item>
            <title>C# 4.0 Named Parameters for better code quality</title>
            <link>http://geekswithblogs.net/michelotti/archive/2009/01/22/c-4.0-named-parameters-for-better-code-quality.aspx</link>
            <description>&lt;p&gt;Sometimes new features are added to a language which fundamentally change how we do things (e.g., when generics was added to .NET 2.0). However, there are other times when features are added to the language that are “syntax sugar” or “nice to have’s”. My outlook on those items has always been that “syntax sugar” is typically a good thing – if there is some feature that allows the code to be more expressive/readable then that is a great thing. Sure, the IL might not be any different behind the scenes but you want your code to be as understandable as possible and developers that come behind you can easily understand what your intent was.&lt;/p&gt;  &lt;p&gt;To that end, I believe that named parameters being added to C# 4.0 is a good thing. I’m certainly not advocating that named parameters be used for every method call but there are several instances where this is going to be helpful in terms of code readabilty. Often you see argument passed to a method and you have no idea what the parameters are for.  Brad Abrams has a nice design guidelines post regarding &lt;a href="http://blogs.msdn.com/brada/archive/2004/01/12/57922.aspx" target="_blank"&gt;Enums vs bool arguments&lt;/a&gt; which talks about this very thing. He discusses that enums are often a better choice than Boolean for method parameters because they express intent more clearly.  So in the case where you can’t control the method you are already calling, you can use named parameters to better express intent.&lt;/p&gt;  &lt;p&gt;Consider this line of code:&lt;/p&gt; &lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;File.Copy(&lt;span class="str"&gt;"source.txt"&lt;/span&gt;, &lt;span class="str"&gt;"destination.txt"&lt;/span&gt;, &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Unless you’re a developer that is already familiar with this method, you can only guess as to what the last Boolean parameter is for.  With C# 4.0 named parameters this code can be written like this to more clearly express intent:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;File.Copy(&lt;span class="str"&gt;"source.txt"&lt;/span&gt;, &lt;span class="str"&gt;"destination.txt"&lt;/span&gt;, overwrite: &lt;span class="kwrd"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;Object initializers, while typically used in the context of LINQ, can also be used as a stand-alone language feature to express intent more clearly. For example, this snippet of code:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;Person person = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;person.FirstName = &lt;span class="str"&gt;"John"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;person.LastName = &lt;span class="str"&gt;"Smith"&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;person.DateOfBirth = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(1970, 1, 1);&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;can be re-written with object initializers like this to be more concise and better express intent:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;Person person = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person() { FirstName = &lt;span class="str"&gt;"John"&lt;/span&gt;, LastName=&lt;span class="str"&gt;"Smith"&lt;/span&gt;, DateOfBirth = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(1970, 1, 1)};&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;It’s as if you can use constructor like syntax to initialize the object – but it’s *more* readable than a constructor because the object initializer uses the property names so it’s obvious what is happening and what properties are being assigned to.  Of course, you can only use that type of syntax in C# 3.0 IF all three of those properties have publicly accessible setters.  What happens if you actually do have a constructor definition that looks like this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; Person(&lt;span class="kwrd"&gt;string&lt;/span&gt; firstName, &lt;span class="kwrd"&gt;string&lt;/span&gt; lastName, DateTime dateOfBirth)&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;In that case, you have no other option in C# 3.0 other than to invoke the constructor like this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;Person person = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person(&lt;span class="str"&gt;"John"&lt;/span&gt;, &lt;span class="str"&gt;"Smith"&lt;/span&gt;, &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(1970, 1, 1));&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;So it’s not 100% obvious what is being assigned in the constructor (e.g., that third DateTime parameter might be date of birth, might be date hired, who knows).  In C# 4.0, you can invoke the constructor like this:&lt;/p&gt;
&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;Person person = &lt;span class="kwrd"&gt;new&lt;/span&gt; Person(firstName: &lt;span class="str"&gt;"John"&lt;/span&gt;, lastName: &lt;span class="str"&gt;"Smith"&lt;/span&gt;, dateOfBirth: &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(1970, 1, 1));&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;This expresses intent clearly and makes the code more understandable.  Again, named parameters should not be used gratuitously but there are many instances where it can make your code higher quality.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128922"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128922" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/michelotti/aggbug/128922.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Michelotti</dc:creator>
            <guid>http://geekswithblogs.net/michelotti/archive/2009/01/22/c-4.0-named-parameters-for-better-code-quality.aspx</guid>
            <pubDate>Fri, 23 Jan 2009 02:51:04 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/michelotti/comments/128922.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/michelotti/archive/2009/01/22/c-4.0-named-parameters-for-better-code-quality.aspx#feedback</comments>
            <slash:comments>11</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/michelotti/comments/commentRss/128922.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/michelotti/services/trackbacks/128922.aspx</trackback:ping>
        </item>
    </channel>
</rss>