<?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>willcodeforcoffee.com &#187; C# 3.5 Features</title>
	<atom:link href="http://willcodeforcoffee.com/category/c-35-features/feed/" rel="self" type="application/rss+xml" />
	<link>http://willcodeforcoffee.com</link>
	<description>The personal programming blog of Eric Hoff.</description>
	<lastBuildDate>Tue, 02 Mar 2010 17:06:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>PHP CodeIgniter vs. ASP.NET MVC &#8211; My Choice</title>
		<link>http://willcodeforcoffee.com/2008/08/06/php-codeigniter-vs-aspnet-mvc-my-choice/</link>
		<comments>http://willcodeforcoffee.com/2008/08/06/php-codeigniter-vs-aspnet-mvc-my-choice/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 13:13:01 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C# 3.5 Features]]></category>
		<category><![CDATA[CodeIgniter]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=34</guid>
		<description><![CDATA[I think it&#8217;s really great that they&#8217;re building an MVC product for ASP.NET at Microsoft!  I think it has the possibility to bring a lot of PHP, Python and Ruby guys onto the platform. But it&#8217;s not ready to use yet so I&#8217;m going to use CodeIgniter.  Sure people are out there coding with the [...]]]></description>
			<content:encoded><![CDATA[<p>I think it&#8217;s really great that they&#8217;re building an MVC product for ASP.NET at Microsoft!  I think it has the possibility to bring a lot of PHP, Python and Ruby guys onto the platform.</p>
<p>But it&#8217;s not ready to use yet so I&#8217;m going to use CodeIgniter.  Sure people are out there coding with the beta, or I could even use plain ol&#8217; Web Forms, but long story short: it isn&#8217;t ready.  It&#8217;s going to be awesome when it&#8217;s done, it&#8217;s awesome now, but every new beta brings out breaking changes.</p>
<p>So even though it makes me sad to leave my beloved C# for one site, I&#8217;m gonna have to stick with PHP for this one.</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2008/08/06/php-codeigniter-vs-aspnet-mvc-my-choice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using var And Living With The Consequences</title>
		<link>http://willcodeforcoffee.com/2008/06/20/using-var-and-living-with-the-consequences/</link>
		<comments>http://willcodeforcoffee.com/2008/06/20/using-var-and-living-with-the-consequences/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 23:06:15 +0000</pubDate>
		<dc:creator>eric</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[C# 3.5 Features]]></category>

		<guid isPermaLink="false">http://willcodeforcoffee.com/?p=28</guid>
		<description><![CDATA[Another new feature added in C# 3.5 to accommodate anonymous types is the introduction of the var type keyword.&#160; In his Coding Horror blog Jeff Atwood is extolling the virtues of using var to reduce type declaration redundancy.&#160; His example is converting: StringBuilder sb = new StringBuilder(256); UTF8Encoding e = new UTF8Encoding(); MD5CryptoServiceProvider md5 = [...]]]></description>
			<content:encoded><![CDATA[<p>Another new feature added in C# 3.5 to accommodate anonymous types is the introduction of the <em><a href="http://msdn.microsoft.com/en-us/library/bb383973.aspx" target="_blank">var</a></em> type keyword.&#160; In his <a href="http://www.codinghorror.com/blog/archives/001136.html" target="_blank">Coding Horror</a> blog Jeff Atwood is extolling the virtues of using var to reduce type declaration redundancy.&#160; His example is converting:</p>
</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:ed0cf444-796c-435c-bb51-002172817e68" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #000000;">StringBuilder sb </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> StringBuilder(</span><span style="color: #800080;">256</span><span style="color: #000000;">);
UTF8Encoding e </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> UTF8Encoding();
MD5CryptoServiceProvider md5 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MD5CryptoServiceProvider();
</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
</p>
<p>into this:</p>
<div class="wlWriterSmartContent" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E7:753422c6-a429-4bd1-a415-abda65ace6ca" style="padding-right: 0px; display: inline; padding-left: 0px; float: none; padding-bottom: 0px; margin: 0px; padding-top: 0px">
<pre style="background-color:White;;overflow: auto;">
<div><!--

Code highlighting produced by Actipro CodeHighlighter (freeware)

http://www.CodeHighlighter.com/

--><span style="color: #000000;">var sb </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> StringBuilder(</span><span style="color: #800080;">256</span><span style="color: #000000;">);
var e </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> UTF8Encoding();
var md5 </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #0000FF;">new</span><span style="color: #000000;"> MD5CryptoServiceProvider();
</span></div>
</pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>His point is that declaring the type as StringBuilder and then <u>assigning it a new StringBuilder</u> is redundant &#8211; StringBuilder appears twice on that line of code, before and after the assignment operator (=).&#160; He makes an excellent point because the example using var is far more concise than the original example.&#160; Furthermore, we should be more interested in what is being assigned than what we&#8217;re assigning too (at least on that line of code).&#160; I find when I read the first block my eyes stick on the left-hand side of the assignment, but in the second example I read the right-hand side code instead.</p>
<p>As a side note. the excellent tool <a href="http://www.jetbrains.com/resharper/index.html" target="_blank">ReSharper 4.0</a> suggests using var for <em>every</em> local variable declaration by default.&#160; It&#8217;s one of the first things I changed in ReSharper when I started using it.</p>
<p>You see, I don&#8217;t entirely agree with using var.&#160; Using var is fine, but we aren&#8217;t converting C# into a dynamically typed language like Python or JavaScript &#8211; C# is still statically typed, using var just forces the compiler to figure out the type you&#8217;re using, usually based on the first value assigned to it.&#160; In Python or JavaScript I could take sb from the above example and assign to it the UTF8Encoding() object reference on the next line, but C# won&#8217;t let you do that, the compiler will give you an error.</p>
<p>I don&#8217;t like the illusion, so where possible I will use var, but I&#8217;ll keep using types too when necessary for clarity.</p>
]]></content:encoded>
			<wfw:commentRss>http://willcodeforcoffee.com/2008/06/20/using-var-and-living-with-the-consequences/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
