<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Technology</title><link>http://codeforeternity.com/blogs/technology/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/codeforeternity/technology" type="application/rss+xml" /><feedburner:emailServiceId>codeforeternity/technology</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><feedburner:feedFlare href="http://add.my.yahoo.com/rss?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforeternity%2Ftechnology" src="http://us.i1.yimg.com/us.yimg.com/i/us/my/addtomyyahoo4.gif">Subscribe with My Yahoo!</feedburner:feedFlare><feedburner:feedFlare href="http://www.newsgator.com/ngs/subscriber/subext.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforeternity%2Ftechnology" src="http://www.newsgator.com/images/ngsub1.gif">Subscribe with NewsGator</feedburner:feedFlare><feedburner:feedFlare href="http://feeds.my.aol.com/add.jsp?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforeternity%2Ftechnology" src="http://o.aolcdn.com/favorites.my.aol.com/webmaster/ffclient/webroot/locale/en-US/images/myAOLButtonSmall.gif">Subscribe with My AOL</feedburner:feedFlare><feedburner:feedFlare href="http://www.bloglines.com/sub/http://feeds.feedburner.com/codeforeternity/technology" src="http://www.bloglines.com/images/sub_modern11.gif">Subscribe with Bloglines</feedburner:feedFlare><feedburner:feedFlare href="http://www.netvibes.com/subscribe.php?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforeternity%2Ftechnology" src="http://www.netvibes.com/img/add2netvibes.gif">Subscribe with Netvibes</feedburner:feedFlare><feedburner:feedFlare href="http://fusion.google.com/add?feedurl=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforeternity%2Ftechnology" src="http://buttons.googlesyndication.com/fusion/add.gif">Subscribe with Google</feedburner:feedFlare><feedburner:feedFlare href="http://www.pageflakes.com/subscribe.aspx?url=http%3A%2F%2Ffeeds.feedburner.com%2Fcodeforeternity%2Ftechnology" src="http://www.pageflakes.com/ImageFile.ashx?instanceId=Static_4&amp;fileName=ATP_blu_91x17.gif">Subscribe with Pageflakes</feedburner:feedFlare><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>iPhoneKicks.com RSS Widget Launched</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/cbev-x9Hfh0/iphonekicks-com-rss-widget-launched.aspx</link><pubDate>Mon, 29 Dec 2008 11:34:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:294</guid><dc:creator>raj</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=294</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/12/29/iphonekicks-com-rss-widget-launched.aspx#comments</comments><description>Check out http://www.iphonekicks.com/docs/widget&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=294" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=lzCD1RHW"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=9EWtMvw7"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=dEfodFBU"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=dEfodFBU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=BkutUBCR"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=BkutUBCR" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=gMnJHnSM"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=o0VHQt9v"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=o0VHQt9v" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=neAsE6h9"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=A88mjq63"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=A88mjq63" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=nVrqal7w"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=5tIkA17q"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=5tIkA17q" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=goxGiQlj"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/cbev-x9Hfh0" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Mobile/default.aspx">Mobile</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/iPhone+SDK/default.aspx">iPhone SDK</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/12/29/iphonekicks-com-rss-widget-launched.aspx</feedburner:origLink></item><item><title>New Social Bookmarking Site for iPhone SDK launched</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/f3ROerfUgtQ/new-social-bookmarking-site-for-iphone-sdk-launched.aspx</link><pubDate>Sun, 07 Dec 2008 09:50:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:288</guid><dc:creator>raj</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=288</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/12/07/new-social-bookmarking-site-for-iphone-sdk-launched.aspx#comments</comments><description>&lt;p&gt;Me and my friend just launched a new social bookmarking site for iPhone SDK. It specialises in iPhone SDK development techniques, technologies and tools including Xcode, iPhone Simulator, Instruments, Interface Builder, SQLite, OpenGL ES, Cocoa.&lt;/p&gt;
&lt;p&gt;Check out &lt;a href="http://www.iphonekicks.com/"&gt;http://www.iPhoneKicks.com&lt;/a&gt; is a community based news site edited by their members.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=288" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=zYFT4Kzq"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=lkvJ8Cj3"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=MdSkAESM"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=MdSkAESM" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=hFGTIl3S"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=hFGTIl3S" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=GQLxcvCU"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=KR9zyw3K"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=KR9zyw3K" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=59Krd6VU"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=0aipfleJ"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=0aipfleJ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=xG5sGkR2"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=uXEPHqHi"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=uXEPHqHi" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=bSZNaEIg"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/f3ROerfUgtQ" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Mobile/default.aspx">Mobile</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/12/07/new-social-bookmarking-site-for-iphone-sdk-launched.aspx</feedburner:origLink></item><item><title>MSDTC on server '[SERVER NAME]' is unavailable</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/Q9290CBqDGE/msdtc-on-server-server-name-is-unavailable.aspx</link><pubDate>Fri, 05 Dec 2008 13:14:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:285</guid><dc:creator>raj</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=285</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/12/05/msdtc-on-server-server-name-is-unavailable.aspx#comments</comments><description>&lt;p&gt;If your code uses distributed transactions and you get the &amp;quot;&lt;strong&gt;MSDTC on server &amp;#39;[SERVER NAME]&amp;#39; is unavailable&lt;/strong&gt;&amp;quot; error, all you have to do to fix it is go to the Services console on your server and start the &lt;strong&gt;Distributed Transaction Coordinator&lt;/strong&gt; service.&lt;/p&gt;
&lt;p&gt;On Vista, you can click on Start &amp;gt; Administrative Tools &amp;gt; Services to go to the Services console.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=285" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Ibjl6AZo"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=RKlDacgs"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=NMJHtGZU"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=NMJHtGZU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=BUPzrWOw"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=BUPzrWOw" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=GLPmqf2V"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=8BL7IFvl"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=8BL7IFvl" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=mhBQM9BD"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=9yeDScM0"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=9yeDScM0" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=QWZX9W7Q"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=vRDi5RTm"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=vRDi5RTm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=TLJZtW8m"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/Q9290CBqDGE" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Vista/default.aspx">Vista</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/SQL+Server/default.aspx">SQL Server</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Windows+Server/default.aspx">Windows Server</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/12/05/msdtc-on-server-server-name-is-unavailable.aspx</feedburner:origLink></item><item><title>LINQ ElementAt and ElementAtOrDefault</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/PpGsnzoJ-Jc/linq-elementat-and-elementatordefault.aspx</link><pubDate>Wed, 13 Aug 2008 14:02:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:253</guid><dc:creator>raj</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=253</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/08/13/linq-elementat-and-elementatordefault.aspx#comments</comments><description>&lt;p&gt;We can use the ElementAt extension method of LINQ to return the element at a specified index (zero based) in a sequence. However the ElementAt extension method would throw the System.ArguementOutOfRangeException when the specified index is a negative value or not less than the size of the sequence. In such a scenario, we can use the ElementAtOrDefault extenion method which would return the default value of a type instead of throwing the System.ArguementOutOfRangeException.&lt;/p&gt;
&lt;p&gt;Code example (both in C# and VB.NET) with comments below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;int&amp;gt; l = new List&amp;lt;int&amp;gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1); &lt;font color="#008000"&gt;// Add 1 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5); &lt;font color="#008000"&gt;// Add 5 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3); &lt;font color="#008000"&gt;// Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 1 as 1 exists at index 0&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int value = l.ElementAt(0);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 3 as 3 exists at index 2&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.ElementAt(2);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list exists at index 3&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.ElementAtOrDefault(3);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Throws System.ArguementOutOfRangeException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list exists at index 3&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.ElementAt(3);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB.NET:&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim l As New List(Of Integer)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1) &lt;font color="#008000"&gt;&amp;#39; Add 1 to the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5) &lt;font color="#008000"&gt;&amp;#39; Add 5 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3) &lt;font color="#008000"&gt;&amp;#39; Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 1 as 1 exists at index 0&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim value As Integer = l.ElementAt(0)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 3 as 3 exists at index 2&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.ElementAt(2)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list exists at index 3 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.ElementAtOrDefault(3)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Throws System.ArguementOutOfRangeException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list exists at index 3 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.ElementAt(3)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=253" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=q1FBHSXl"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=gjrkyCmm"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Pfl4UVyx"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=Pfl4UVyx" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=YCRUUR5F"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=YCRUUR5F" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=AI8yefVu"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Z86DJJWY"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=Z86DJJWY" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=uHpfm59M"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=g2nmTtIh"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=g2nmTtIh" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Ta0DN1kT"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=cGB6lher"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=cGB6lher" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=1CZ2G7Ex"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/PpGsnzoJ-Jc" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/08/13/linq-elementat-and-elementatordefault.aspx</feedburner:origLink></item><item><title>T-SQL Function to Get Int From Varchar</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/VO8ljEBimHA/t-sql-function-to-get-int-from-varchar.aspx</link><pubDate>Tue, 20 May 2008 10:48:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:195</guid><dc:creator>raj</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=195</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/05/20/t-sql-function-to-get-int-from-varchar.aspx#comments</comments><description>&lt;p&gt;I recently had to write a T-SQL function which cleans up all non numeric characters from a varchar variable and returns the int value of the remaining numeric characters. If no numeric characters exist, the function should return zero. I thought it would be nice to share this with you and I hope you find this useful ;-) Here is the function:&lt;/p&gt;
&lt;div style="OVERFLOW:auto;WIDTH:100%;HEIGHT:100%;"&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CREATE FUNCTION [dbo].[GetIntFromVarchar]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @originalString varchar(50)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURNS int&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; AS&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- declare local variable to hold numeric characters&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- and assign default value of empty string&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DECLARE @retVal varchar(50)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @retVal = &amp;#39;&amp;#39;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- declare local variable to loop through @originalString&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- and assign initial value of 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DECLARE @loop int&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @loop = 1&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- loop through every character in @originalString&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WHILE @loop &amp;lt;= LEN(@originalString) &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF ISNUMERIC(SUBSTRING(@originalString, @loop, 1)) = 1&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- if numeric character found, append it to @retVal&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @retVal = @retVal + SUBSTRING(@originalString, @loop, 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @loop = @loop + 1 -- increment value of @loop by 1&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- set @retVal to &amp;#39;0&amp;#39; if no numeric characters found&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF @retVal = &amp;#39;&amp;#39;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BEGIN&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET @retVal = &amp;#39;0&amp;#39;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- return int value of numeric characters found &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -- by casting @retVal to int&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RETURN CAST(@retVal as int)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; END&lt;/font&gt;&lt;/p&gt;&lt;/div&gt;
&lt;p&gt;Once you have created this function, execute below T-SQL statements to verify the same:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRINT dbo.GetIntFromVarchar(&amp;#39;R1A2J3&amp;#39;) -- returns 123&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRINT dbo.GetIntFromVarchar(&amp;#39;COOL456CODER&amp;#39;) -- returns 456&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRINT dbo.GetIntFromVarchar(&amp;#39;789&amp;#39;) -- returns 789&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; PRINT dbo.GetIntFromVarchar(&amp;#39;GEEK&amp;#39;) -- returns 0&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=195" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=gzOcLUqI"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=KFxTi7j1"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=qDYFceqT"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=qDYFceqT" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=veghNe0o"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=veghNe0o" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=cJ7soCy1"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=L9VwsK2Q"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=L9VwsK2Q" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=CGOiAARd"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Vd9TvEuZ"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=Vd9TvEuZ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=jEwCJGxH"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=cIcl1jWI"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=cIcl1jWI" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=7AKI8wId"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/VO8ljEBimHA" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/SQL+Server/default.aspx">SQL Server</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/05/20/t-sql-function-to-get-int-from-varchar.aspx</feedburner:origLink></item><item><title>Developers are Born Brave</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/PXlcLwWabjs/developers-are-born-brave.aspx</link><pubDate>Fri, 16 May 2008 16:15:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:186</guid><dc:creator>raj</dc:creator><slash:comments>11</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=186</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/05/16/developers-are-born-brave.aspx#comments</comments><description>&lt;p&gt;Reality about software development. Below image says it all ;-) Cheers to every coder reading this blog post&amp;nbsp;:-) Please scroll to the right if you cannot see the entire image at 1 glance or click&amp;nbsp;&lt;a class="" title="Developers are Born Brave" href="http://codeforeternity.com/blogs/technology/DevelopersAreBornBrave_Small.jpg" target="_blank"&gt;here&lt;/a&gt;&amp;nbsp;to view / download the image in a seperate window.&lt;/p&gt;
&lt;div style="OVERFLOW:auto;WIDTH:100%;HEIGHT:400px;"&gt;&lt;img height="393" alt="Developers are Born Brave" src="http://codeforeternity.com/blogs/technology/DevelopersAreBornBrave_Small.jpg" width="840" border="0" /&gt;&lt;/div&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=186" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Vbu0KrjH"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=tiolLGZM"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=fsYjs5r1"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=fsYjs5r1" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=bgAvUjBL"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=bgAvUjBL" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=9zMgcP8X"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=hHfrXfSt"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=hHfrXfSt" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=gV0GHmyi"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=vgFJ2CoZ"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=vgFJ2CoZ" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=dlOlfyu6"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=0ko8at0Y"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=0ko8at0Y" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=AuhmiszA"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/PXlcLwWabjs" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Management/default.aspx">Management</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Humor/default.aspx">Humor</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/05/16/developers-are-born-brave.aspx</feedburner:origLink></item><item><title>Coders versus Project Managers</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/pfHxARUmPss/coders-versus-project-managers.aspx</link><pubDate>Wed, 14 May 2008 10:15:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:177</guid><dc:creator>raj</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=177</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/05/14/coders-versus-project-managers.aspx#comments</comments><description>&lt;p&gt;Few months back, I got below joke emailed to me by my friend who is also a passionate coder. In my personal (and humble) opinion, below joke hits jackpot with the current state of 9 out of 10 IT companies in India, which are headed by people who have zero or very little technical background. And perhaps this explains why Indian IT companies still have to market themselves as low cost outsourcing destinations to win business any why we still dont have too many Product based IT companies in India :-) Is the story same in your country too?&amp;nbsp;Let me know, I would love to hear :-)&lt;/p&gt;
&lt;p&gt;Here is the joke, enjoy and forward this to all your coder friends ;-)&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;A woman in a hot air balloon realized she was lost.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;She reduced altitude and spotted a man below. She descended a bit more and shouted, &amp;quot;Excuse me, can you help me? I promised a friend I would meet him an hour ago but I don&amp;#39;t know where I am.&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;The man below replied, &amp;quot;You&amp;#39;re in a hot air balloon hovering approximately 30 feet above the ground. You&amp;#39;re between 40 and 41 degrees north latitude and between 59 and 60 degrees west longitude.&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;quot;You must be an engineer&amp;quot; said the balloonist.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;quot;I am&amp;quot;, replied the man. &amp;quot;How did you know?&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;quot;Well&amp;quot;, answered the balloonist, &amp;quot;everything you told me is technically correct, but I&amp;#39;ve no idea what to make of your information, and the fact is I&amp;#39;m still lost. Frankly, you&amp;#39;ve not been much help at all. If anything you&amp;#39;ve delayed my trip even more.&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;The man below responded, &amp;quot;You must be in management.&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;quot;I am,&amp;quot; replied the balloonist, &amp;quot;but how did you know?&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;quot;Well&amp;quot;, said the man, &amp;quot;You don&amp;#39;t know where you are or where you&amp;#39;re going. You have risen to where you are due to a large quantity of hot air. You made a promise which you&amp;#39;ve no idea how to keep, and you expect people beneath you to solve your problems&amp;quot;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=177" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=O1Tpluoc"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=TYtq2xrv"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=T92vCzCW"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=T92vCzCW" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=PXzzR51l"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=PXzzR51l" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=1jVK8Zxq"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=TD36YPFm"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=TD36YPFm" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=4ZebG0cL"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=iAaD4wBl"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=iAaD4wBl" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Jm7jyHpC"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=RrSO8Oyo"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=RrSO8Oyo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=nLjhBn2m"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/pfHxARUmPss" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Management/default.aspx">Management</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Humor/default.aspx">Humor</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/05/14/coders-versus-project-managers.aspx</feedburner:origLink></item><item><title>LINQ Single and SingleOrDefault</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/_yqI2wx-FDg/linq-single-and-singleordefault.aspx</link><pubDate>Sat, 10 May 2008 13:27:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:167</guid><dc:creator>raj</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=167</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/05/10/linq-single-and-singleordefault.aspx#comments</comments><description>&lt;p&gt;We can use the Single extension method of LINQ to return the only element in a sequence that satisfies a specified condition. However the Single extension method would throw the System.InvalidOperationException when no element in a sequence satisfies a specified condition. In such a scenario, we can use the SingleOrDefault extenion method which would return the default value of a type instead of throwing the System.InvalidOperationException.&lt;/p&gt;
&lt;p&gt;Also, both Single as well as SingleOrDefault&amp;nbsp;extension methods would throw the System.InvalidOperationException when more than one element in a sequence satisfy a specified condition. We can use&amp;nbsp;&lt;a class="" title="LINQ First and FirstOrDefault" href="http://codeforeternity.com/blogs/technology/archive/2008/04/25/linq-first-and-firstordefault-methods.aspx" target="_blank"&gt;First&lt;/a&gt; or&amp;nbsp;&lt;a class="" title="LINQ Last and LastOrDefault" href="http://codeforeternity.com/blogs/technology/archive/2008/04/27/linq-last-and-lastordefault-methods.aspx" target="_blank"&gt;Last&lt;/a&gt; extensions methods of LINQ in such scenarios.&lt;/p&gt;
&lt;p&gt;Code example (both in C# and VB.NET) with comments below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;int&amp;gt; l = new List&amp;lt;int&amp;gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1); &lt;font color="#008000"&gt;// Add 1 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5); &lt;font color="#008000"&gt;// Add 5 to the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3); &lt;font color="#008000"&gt;// Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 1 as only 1 satisfies the condition&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int value = l.Single(i =&amp;gt; i == 1);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list equals 4&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.SingleOrDefault(i =&amp;gt; i == 4);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Throws System.InvalidOperationException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list equals 4 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Single(i =&amp;gt; i == 4);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Throws System.InvalidOperationException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since both 5 and 3 are greater than 1 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Single(i =&amp;gt; i &amp;gt; 1);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.SingleOrDefault(i =&amp;gt; i &amp;gt; 1);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB.NET:&amp;nbsp;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim l As New List(Of Integer)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1) &lt;font color="#008000"&gt;&amp;#39; Add 1 to the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5) &lt;font color="#008000"&gt;&amp;#39; Add 5 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3) &lt;font color="#008000"&gt;&amp;#39; Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 1 as only 1 satisfies the condition&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim value As Integer = l.Single(Function(i) i = 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list equals 4&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.SingleOrDefault(Function(i) i = 4)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Throws System.InvalidOperationException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list equals 4&amp;nbsp;&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Single(Function(i) i = 4)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Throws System.InvalidOperationException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since both 5 and 3 are greater than 1 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Single(Function(i) i &amp;gt; 1)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.SingleOrDefault(Function(i) i &amp;gt; 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=167" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=x08xRVib"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=rTSe3sJ9"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=ktqtkPv6"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=ktqtkPv6" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=7H6bVQvY"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=7H6bVQvY" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=5wpNzZDk"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=2iccwC2C"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=2iccwC2C" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=2Yr9eHU3"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Ek3U2zu4"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=Ek3U2zu4" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=MuFzv53Z"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=qCJdOBTT"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=qCJdOBTT" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=aR9a1JCH"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/_yqI2wx-FDg" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/05/10/linq-single-and-singleordefault.aspx</feedburner:origLink></item><item><title>AddItem Extension Method for BulletedList, CheckBoxList, DropDownList, ListBox, RadioButtonList</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/EVSioxN6zzg/additem-extension-method-for-bulletedlist-checkboxlist-dropdownlist-listbox-radiobuttonlist.aspx</link><pubDate>Fri, 09 May 2008 15:03:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:164</guid><dc:creator>raj</dc:creator><slash:comments>9</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=164</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/05/09/additem-extension-method-for-bulletedlist-checkboxlist-dropdownlist-listbox-radiobuttonlist.aspx#comments</comments><description>&lt;p&gt;We would have to write the below code to add a new item (with value) to any of these 5 controls (BulletedList, CheckBoxList, DropDownList, ListBox, RadioButtonList)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bulletedList.Items.Add(new ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; checkBoxList.Items.Add(new ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropDownList.Items.Add(new ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listBox.Items.Add(new ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioButtonList.Items.Add(new ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;));&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bulletedList.Items.Add(New ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; checkBoxList.Items.Add(New ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropDownList.Items.Add(New ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listBox.Items.Add(New ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioButtonList.Items.Add(New ListItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;))&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;I find it quite painful to write so much code just to add a new item (with value) to these controls and so I created a new AddItem extension method for the ListControl class (since all these 5 controls inherit from the ListControl class)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void AddItem(this ListControl lc, string text, string value)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lc.Items.Add(new ListItem(text, value));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Extension()&amp;gt; _&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Sub AddItem(ByVal lc As ListControl, ByVal text As String, ByVal value As String)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lc.Items.Add(New ListItem(text, value))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Sub&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Now I can simply write the above code in a much simpler and cleaner way like below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bulletedList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; checkBoxList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropDownList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listBox.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioButtonList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bulletedList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; checkBoxList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dropDownList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listBox.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; radioButtonList.AddItem(&amp;quot;text&amp;quot;, &amp;quot;value&amp;quot;)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Just 1 extension method which works for 5 controls to solve the problem :-) Cheers to object inheritance and cheers to Extension Methods ;-)&lt;/p&gt;
&lt;p&gt;Note: You can find a list of other cool and useful Extension Methods coded by me &lt;a class="" href="http://codeforeternity.com/tags/Extension+Methods/default.aspx" target="_blank"&gt;here&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=164" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=h7YIE1hJ"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=UfkjC3cB"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=WIu3sn5t"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=WIu3sn5t" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=O3pxgCkp"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=O3pxgCkp" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=RlqS86EW"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=m9gUDsu5"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=m9gUDsu5" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=jDxLXMFe"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=5yBvFMRt"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=5yBvFMRt" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=8FmzBYAP"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=gldr84wk"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=gldr84wk" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=g3pRp78A"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/EVSioxN6zzg" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Code+Better/default.aspx">Code Better</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/ASP.NET/default.aspx">ASP.NET</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Extension+Methods/default.aspx">Extension Methods</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/05/09/additem-extension-method-for-bulletedlist-checkboxlist-dropdownlist-listbox-radiobuttonlist.aspx</feedburner:origLink></item><item><title>Using Initial Capacity Constructor of StringBuilder for Extreme Performace</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/Y8ueqWA01C0/using-initial-capacity-constructor-of-stringbuilder-for-extreme-performace.aspx</link><pubDate>Thu, 08 May 2008 12:13:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:161</guid><dc:creator>raj</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=161</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/05/08/using-initial-capacity-constructor-of-stringbuilder-for-extreme-performace.aspx#comments</comments><description>&lt;p&gt;You must have come across plenty of articles on the internet which talk about using the StringBuilder class when computing large strings for performance gains. Nothing wrong with that. However I have not seen many coders using the Initial Capacity constructor of the StringBuilder class which can further&amp;nbsp;improve performace.&lt;/p&gt;
&lt;p&gt;Lets take a real world example. Suppose we had to&amp;nbsp;compute a csv (comma seperated values) file for a table named Users which had the following structure:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;UserID int&lt;/li&gt;
&lt;li&gt;FirstName nvarchar(20)&lt;/li&gt;
&lt;li&gt;LastName nvarchar(20)&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Our csv file would look like (for 2 records):&lt;/p&gt;
&lt;p&gt;1,Paul,Graham&lt;br /&gt;2,Scott,Guthrie&lt;/p&gt;
&lt;p&gt;Most coders would write the&amp;nbsp;below code to compute the csv file:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Populate Users DataTable&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataTable dtUsers = SomeFunctionWhichReturnsUsersDataTable();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Declare new StringBuilder&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Text.StringBuilder sb = new System.Text.StringBuilder();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Loop through Users DataTable&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int&amp;nbsp;j = 0;&amp;nbsp;j &amp;lt; dtUsers.Rows.Count; j++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(dtUsers.Rows[j][&amp;quot;UserID&amp;quot;].ToString()); &lt;font color="#008000"&gt;// Append UserID&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(&amp;quot;,&amp;quot;); &lt;font color="#008000"&gt;// Append comma&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(dtUsers.Rows[j][&amp;quot;FirstName&amp;quot;].ToString()); &lt;font color="#008000"&gt;// Append FirstName&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(&amp;quot;,&amp;quot;); &lt;font color="#008000"&gt;// Append comma&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(dtUsers.Rows[j][&amp;quot;LastName&amp;quot;].ToString()); &lt;font color="#008000"&gt;// Append LastName&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendLine(); &lt;font color="#008000"&gt;// Append new line&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return sb.ToString(); &lt;font color="#008000"&gt;// Return StringBuilder contents&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Now lets write the above code more intelligently by using the Initial Capacity constructor of the StringBuilder class. We can actually guess the approximate length of the csv file before hand by considering below points:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Max length of UserID can be 10 characters, since max value of UserID can be 2147483647, since its datatype is int&lt;/li&gt;
&lt;li&gt;Max length of FirstName can be 20 characters, since its datatype is nvarchar(20)&lt;/li&gt;
&lt;li&gt;Max length of LastName can be 20 characters, since its datatype is nvarchar(20)&lt;/li&gt;
&lt;li&gt;Also each csv file record has 2 comma characters which act as seperators, and 1 new line character&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Therefore the max length per record can be 54 characters (10[UserID] + 20[FirstName] + 20[LastName] + 2[2 comma characters] + 2[1 new line character]). So&amp;nbsp;now we are absolutely sure that our csv file would have a max length of (54 * Number of Records) characters.&lt;/p&gt;
&lt;p&gt;If you are hell bent on having just one and only one memory allocation for the StringBuilder class, go ahead and set the Initial Capacity of the StringBuilder class&amp;nbsp;to (54 * Number of Rows). However doing this would more often than not result in a lot of memory wastage as not all records would have their UserID set to 10 digit integers or their FirstName and LastName set to 20 character long strings. Therefore I usually follow the divide by 2 rule where I divide the max length per record value by 2. This way I am sure there wont ever be more than 2 memory (re)allocations and more often than not just a single memory allocation would do the job. Below is the intelligent version of above code:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Populate Users DataTable&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataTable dtUsers = SomeFunctionWhichReturnsUsersDataTable();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set a value of 54 to maxLengthPerRecord&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int maxLengthPerRecord = 54;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Apply divide by 2 rule&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; maxLengthPerRecord = maxLengthPerRecord / 2;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Compute initialCapacity value&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int initialCapacity = dtUsers.Rows.Count * maxLengthPerRecord; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Declare new StringBuilder using the Initial Capacity constructor&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; System.Text.StringBuilder sb = new System.Text.StringBuilder(initialCapacity);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Loop through Users DataTable&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (int&amp;nbsp;j = 0;&amp;nbsp;j &amp;lt; dtUsers.Rows.Count; j++) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(dtUsers.Rows[j][&amp;quot;UserID&amp;quot;].ToString()); &lt;font color="#008000"&gt;// Append UserID&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(&amp;quot;,&amp;quot;); &lt;font color="#008000"&gt;// Append comma&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(dtUsers.Rows[j][&amp;quot;FirstName&amp;quot;].ToString()); &lt;font color="#008000"&gt;// Append FirstName&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(&amp;quot;,&amp;quot;); &lt;font color="#008000"&gt;// Append comma&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.Append(dtUsers.Rows[j][&amp;quot;LastName&amp;quot;].ToString()); &lt;font color="#008000"&gt;// Append LastName&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sb.AppendLine(); &lt;font color="#008000"&gt;// Append new line&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return sb.ToString(); &lt;font color="#008000"&gt;// Return StringBuilder contents&lt;/font&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You might be thinking this is&amp;nbsp;too much of an effort to save on a few memory reallocations. But the geek in me tries to visualize the performance gains and number of memory reallocations (read garbage collection cycles which are so expensive) which can be saved if we had to do the same task for a table with many columns and tens of thousands of records :-)&lt;/p&gt;
&lt;p&gt;Note: You can also consider dividing the max length per record by 3 or even 4, it all depends on your data structures and data patterns. Also the above code example uses a DataTable. However you can apply the same logic on a generic list or a DataReader&amp;nbsp;as well.&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=161" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=PaWsTFts"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=FDdYWGvn"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=WmRKia7p"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=WmRKia7p" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=ePcL4n9v"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=ePcL4n9v" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=OV77faRj"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=dJDeFaoA"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=dJDeFaoA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=xBtKW043"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=lCb2ombf"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=lCb2ombf" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=CUbmk0NZ"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=2TOtq8cL"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=2TOtq8cL" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=cgb0EATh"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/Y8ueqWA01C0" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Code+Better/default.aspx">Code Better</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Performance/default.aspx">Performance</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/05/08/using-initial-capacity-constructor-of-stringbuilder-for-extreme-performace.aspx</feedburner:origLink></item><item><title>T-SQL Query to Find the Second Lowest Column Value in a Table</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/e0nmFXosIO4/t-sql-query-to-find-the-second-lowest-column-value-in-a-table.aspx</link><pubDate>Wed, 30 Apr 2008 08:41:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:146</guid><dc:creator>raj</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=146</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/04/30/t-sql-query-to-find-the-second-lowest-column-value-in-a-table.aspx#comments</comments><description>&lt;p&gt;After reading my earlier post &lt;a class="" href="http://codeforeternity.com/blogs/technology/archive/2008/01/10/t-sql-query-to-find-the-second-highest-column-value-in-a-table.aspx" target="_blank"&gt;T-SQL Query to Find the Second Highest Column Value in a Table&lt;/a&gt;&amp;nbsp;a lot of users asked me to also help&amp;nbsp;them with writing a query&amp;nbsp;to find the second lowest column value in a table. So here it is:&amp;nbsp;If we had a table named Employee which had a column named Salary and we had to find the second&amp;nbsp;lowest Salary in the Employee table, the query for the same would be:&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;SELECT&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;TOP&lt;/font&gt;&lt;font size="2"&gt; 1 Salary &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;FROM&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;SELECT&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;TOP&lt;/font&gt;&lt;font size="2"&gt; 2 Salary &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;FROM&lt;/font&gt;&lt;font size="2"&gt; Employee &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;ORDER&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;BY&lt;/font&gt;&lt;font size="2"&gt; Salary &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;ASC&lt;/font&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;AS&lt;/font&gt;&lt;font size="2"&gt; E &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;ORDER&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;BY&lt;/font&gt;&lt;font size="2"&gt; Salary &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;DESC&lt;/p&gt;&lt;/font&gt;
&lt;p&gt;If we ran the above query against the Employee table which had the following 5 rows:&lt;/p&gt;
&lt;p&gt;5000&lt;br /&gt;4000&lt;br /&gt;3000&lt;br /&gt;2000&lt;br /&gt;1000&lt;/p&gt;
&lt;p&gt;The subquery or the inner query would return the top 2 rows in ascending Salary order which would be:&lt;/p&gt;
&lt;p&gt;1000&lt;br /&gt;2000&lt;/p&gt;
&lt;p&gt;The outer query would then select the top 1 row from the subquery results in descending Salary order which would be:&lt;/p&gt;
&lt;p&gt;2000&lt;/p&gt;
&lt;p&gt;Note that if we had to get the fourth lowest Salary, we could do so by simply changing the subquery from TOP 2 to TOP 4&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=146" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=trs1dRXT"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=LZESvhBf"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Una22M2c"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=Una22M2c" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=x59yEHeE"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=x59yEHeE" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=0DuWGXhr"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=UtG5nWGt"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=UtG5nWGt" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=bAgyYnoy"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=lTvRaoQT"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=lTvRaoQT" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Fha78tI4"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=ua7oHdWF"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=ua7oHdWF" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=R7mTpzTx"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/e0nmFXosIO4" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/SQL+Server/default.aspx">SQL Server</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/04/30/t-sql-query-to-find-the-second-lowest-column-value-in-a-table.aspx</feedburner:origLink></item><item><title>LINQ Last and LastOrDefault</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/IF4gqfHsT1A/linq-last-and-lastordefault-methods.aspx</link><pubDate>Sun, 27 Apr 2008 08:31:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:138</guid><dc:creator>raj</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=138</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/04/27/linq-last-and-lastordefault-methods.aspx#comments</comments><description>&lt;p&gt;We can use the Last extension method of LINQ to return the last element in a sequence that satisfies a specified condition. However the Last extension method would throw the System.InvalidOperationException when no element in a sequence satisfies a specified condition. In such a scenario, we can use the LastOrDefault extenion method which would return the default value of a type instead of throwing the System.InvalidOperationException.&lt;/p&gt;
&lt;p&gt;Code example (both in C# and VB.NET) with comments below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;int&amp;gt; l = new List&amp;lt;int&amp;gt;();&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1); &lt;font color="#008000"&gt;// Add 1 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5); &lt;font color="#008000"&gt;// Add 5 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3); &lt;font color="#008000"&gt;// Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 1 as only 1 satisfies the condition&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int value = l.Last(i =&amp;gt; i == 1);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 3 although both 5 and 3 are greater than 1 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since 3 appears last in the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Last(i =&amp;gt; i &amp;gt; 1);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list equals 4&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.LastOrDefault(i =&amp;gt; i == 4);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Throws System.InvalidOperationException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list equals 4 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Last(i =&amp;gt; i == 4);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB.NET:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim l As New List(Of Integer)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1) &lt;font color="#008000"&gt;&amp;#39; Add 1 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5) &lt;font color="#008000"&gt;&amp;#39; Add 5 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3) &lt;font color="#008000"&gt;&amp;#39; Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 1 as only 1 satisfies the condition&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim value As Integer = l.Last(Function(i) i = 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 3 although both 5 and 3 are greater than 1 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since 3 appears last in the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Last(Function(i) i &amp;gt; 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list equals 4&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.LastOrDefault(Function(i) i = 4)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Throws System.InvalidOperationException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list equals 4 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.Last(Function(i) i = 4)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=138" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=5yzu25Nm"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=PgwhL3oR"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=HVsvpWjE"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=HVsvpWjE" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=MJw0KjL9"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=MJw0KjL9" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=QD9R80YE"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=RYHKYc0D"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=RYHKYc0D" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=e2Ib3ECt"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=IPwezGMT"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=IPwezGMT" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=zbRhvwm3"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=6srYMdEd"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=6srYMdEd" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=vv7ZE0co"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/IF4gqfHsT1A" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/04/27/linq-last-and-lastordefault-methods.aspx</feedburner:origLink></item><item><title>LINQ First and FirstOrDefault</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/Nuvq1ESKX5g/linq-first-and-firstordefault-methods.aspx</link><pubDate>Fri, 25 Apr 2008 17:22:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:136</guid><dc:creator>raj</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=136</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/04/25/linq-first-and-firstordefault-methods.aspx#comments</comments><description>&lt;p&gt;We can use the First extension method of LINQ to return the first element in a sequence that satisfies a specified condition. However the First extension method would throw the System.InvalidOperationException when no element in a sequence satisfies a specified condition. In such a scenario, we can use the FirstOrDefault extenion method which would return the default value of a type instead of throwing the System.InvalidOperationException.&lt;/p&gt;
&lt;p&gt;Code example&amp;nbsp;(both in C# and VB.NET)&amp;nbsp;with comments below:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;C#:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; List&amp;lt;int&amp;gt; l = new List&amp;lt;int&amp;gt;(); &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1); &lt;font color="#008000"&gt;// Add 1 to the list&lt;/font&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5); &lt;font color="#008000"&gt;// Add 5 to the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3); &lt;font color="#008000"&gt;// Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 1 as only 1 satisfies the condition&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int value = l.First(i =&amp;gt; i == 1);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns 5 although both 5 and 3 are greater than 1 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since 5 appears first in the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.First(i =&amp;gt; i &amp;gt; 1); &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list equals 4&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.FirstOrDefault(i =&amp;gt; i == 4); &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Throws System.InvalidOperationException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // since no element in the list equals 4 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.First(i =&amp;gt; i == 4); &lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;VB.NET:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Create a new generic list of ints&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim l As New List(Of Integer)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(1) &lt;font color="#008000"&gt;&amp;#39; Add 1 to the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(5) &lt;font color="#008000"&gt;&amp;#39; Add 5 to the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; l.Add(3) &lt;font color="#008000"&gt;&amp;#39; Add 3 to the list&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 1 as only 1 satisfies the condition&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim value As Integer = l.First(Function(i) i = 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns 5 although both 5 and 3 are greater than 1 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since 5 appears first in the list&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.First(Function(i) i &amp;gt; 1)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Returns the default value of int which is 0 &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list equals 4&lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.FirstOrDefault(Function(i) i = 4)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&lt;font color="#008000"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; Throws System.InvalidOperationException &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;#39; since no element in the list equals 4 &lt;br /&gt;&lt;/font&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; value = l.First(Function(i) i = 4)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=136" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=EAUDelMl"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=mJfkAqAq"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=2Za76t1C"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=2Za76t1C" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=YJuJWyGe"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=YJuJWyGe" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=G2EgupO7"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=QJwiyr7I"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=QJwiyr7I" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=YT5s5T6J"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=WIKSFnBP"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=WIKSFnBP" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=yE3cXCIx"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=TH060bYH"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=TH060bYH" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=QNHe31rl"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/Nuvq1ESKX5g" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/04/25/linq-first-and-firstordefault-methods.aspx</feedburner:origLink></item><item><title>Blackle - Energy Saving Search</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/r05D3yn8lqk/blackle-energy-saving-search.aspx</link><pubDate>Thu, 24 Apr 2008 19:45:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:134</guid><dc:creator>raj</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=134</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/04/24/blackle-energy-saving-search.aspx#comments</comments><description>&lt;p&gt;Google is the second brain for many coders hungry for information. I as a coder cannot imagine a single day at work without Google. Few days back (22 April to be precise), it was Earth&amp;#39;s day and I was wondering how we as coders can do our bit for our planet and fight against Global Warming.&amp;nbsp;So I thought I would blog about Blackle :-)&lt;/p&gt;
&lt;p&gt;The idea behind Blackle: Google uses white background which consumes more power, and considering the huge number of queries&amp;nbsp;Google gets (about 200 million each day), according to calculations, a black version of Google would save 750 mega watts / hour per year.&lt;/p&gt;
&lt;p&gt;So next time you want to search for information, try &lt;a class="" href="http://www.blackle.com/" target="_blank"&gt;http://www.blackle.com&lt;/a&gt; :-) For more info on Blackle, visit &lt;a class="" href="http://www.blackle.com/about" target="_blank"&gt;http://www.blackle.com/about&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Also&amp;nbsp;help spread&amp;nbsp;the word about Blackle&amp;nbsp;by telling your coder friends about it, ask them to blog about&amp;nbsp;Blackle incase they have a blog&amp;nbsp;;-)&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=134" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=jc8ikMUq"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=5jvCbHAV"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=2lBBPGcg"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=2lBBPGcg" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=ETFquvOB"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=ETFquvOB" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=7qJ8aY8u"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=ioyOnimY"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=ioyOnimY" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=IWxzul2k"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=Bc8YOCQU"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=Bc8YOCQU" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=3nKVPPVx"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=BFvFiRYb"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=BFvFiRYb" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=ZWAWAtXD"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/r05D3yn8lqk" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Google/default.aspx">Google</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/04/24/blackle-energy-saving-search.aspx</feedburner:origLink></item><item><title>Cool Extension Methods for IDataReader Interface</title><link>http://feedproxy.google.com/~r/codeforeternity/technology/~3/3X_oG_xfEjo/cool-extension-methods-for-idatareader-interface.aspx</link><pubDate>Tue, 15 Apr 2008 22:34:00 GMT</pubDate><guid isPermaLink="false">6581de12-b79f-4db0-af9f-717dfd7c7876:128</guid><dc:creator>raj</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://codeforeternity.com/blogs/technology/rsscomments.aspx?PostID=128</wfw:commentRss><comments>http://codeforeternity.com/blogs/technology/archive/2008/04/15/cool-extension-methods-for-idatareader-interface.aspx#comments</comments><description>&lt;p&gt;I find it really annoying to use the GetOrdinal method of the DataReader class everytime I have to access data in a strongly typed manner using any of the Get[DataType] methods of the DataReader class. Have a look at below code:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int employeeID = dr.GetInt32(dr.GetOrdinal(&amp;quot;EmployeeID&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string firstName = dr.GetString(dr.GetOrdinal(&amp;quot;FirstName&amp;quot;));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool enabled = dr.GetBoolean(dr.GetOrdinal(&amp;quot;Enabled&amp;quot;));&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;It would be so cool if I could directly specify the table column names like below:&lt;/p&gt;
&lt;p&gt;&lt;font face="courier new,courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; int employeeID = dr.GetInt32(&amp;quot;EmployeeID&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; string firstName = dr.GetString(&amp;quot;FirstName&amp;quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; bool enabled = dr.GetBoolean(&amp;quot;Enabled&amp;quot;);&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;This would save me so much typing and make my code look so much cleaner. The power of Extension Methods make this possible :-) I created a new class named IDataReaderHelper which has 18 Extension Methods in all. You can simply pass the table column names instead of table column indexes to all these 18 Extension Methods, and these 18 Extension Methods would take care of the rest by calling the GetOrdinal method of the DataReader class internally :-). Have a look at the screen shot below:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://codeforeternity.com/blogs/technology/IDataReader_01.JPG"&gt;&lt;img src="http://codeforeternity.com/blogs/technology/IDataReader_01.JPG" border="0" alt="" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Note: For readability purpose, above screen shot just highlights 3 of the 18 Extension Methods present in the IDataReaderHelper class. The 18 Extension Methods present in the IDataReaderHelper class are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;GetBoolean&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetByte&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetBytes&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetChar&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetChars&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetData&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetDataTypeName&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetDateTime&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetDecimal&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetDouble&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetFieldType&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetFloat&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetGuid&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetInt16&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetInt32&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetInt64&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetString&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;GetValue&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;You can find&amp;nbsp;the entire source code for the IDataReaderHelper class as an attachment with this post&amp;nbsp;available for download. To see all my posts on Extension Methods click &lt;a class="" title="Extension Methods" href="http://codeforeternity.com/blogs/technology/archive/tags/Extension+Methods/default.aspx" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Guys please dont forget to check out the Chris&amp;#39;s comments (2nd from top)&amp;nbsp;regarding performance issues when using the&amp;nbsp;GetOrdinal method of the DataReader class inside a loop. Thanks for your excellent feedback Chris :-)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; Guys please dont forget to check out programatik&amp;#39;s post&amp;nbsp;&lt;a class="" href="http://programatik.wordpress.com/2008/05/12/benchmarking-do-datareadergetordinal/" target="_blank"&gt;here&lt;/a&gt;&amp;nbsp;where he / she has compared performance (using&amp;nbsp;GetOrdinal versus using int inside a loop). His / her post is in Portuguese&amp;nbsp;so you can go to &lt;a class="" href="http://www.google.com/translate_t" target="_blank"&gt;http://www.google.com/translate_t&lt;/a&gt;&amp;nbsp;and translate programatik&amp;#39;s post&amp;nbsp;from Portuguese to English. It took me 30 minutes to figure out the language of this post ;-) Great work programatik ;-)&lt;/p&gt;
&lt;p&gt;Cheers,&lt;br /&gt;Raj&lt;/p&gt;
&lt;p&gt;~~~ CODING FOR ETERNITY !!! ~~~&lt;/p&gt;&lt;img src="http://codeforeternity.com/aggbug.aspx?PostID=128" width="1" height="1"&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=qXN091o1"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=41" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=XUFqh85L"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=43" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=U9dJITI3"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=U9dJITI3" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=2COX1GEB"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=2COX1GEB" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=49RS8tBz"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=50" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=biamW96u"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=biamW96u" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=VqGooibE"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=52" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=wABG6Tai"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=wABG6Tai" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=quofC84P"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=54" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=CEF82Wq3"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?i=CEF82Wq3" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~f/codeforeternity/technology?a=FTiCHZuQ"&gt;&lt;img src="http://feeds.feedburner.com/~f/codeforeternity/technology?d=129" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/codeforeternity/technology/~4/3X_oG_xfEjo" height="1" width="1"/&gt;</description><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Code+Better/default.aspx">Code Better</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/.NET+3.5/default.aspx">.NET 3.5</category><category domain="http://codeforeternity.com/blogs/technology/archive/tags/Extension+Methods/default.aspx">Extension Methods</category><feedburner:origLink>http://codeforeternity.com/blogs/technology/archive/2008/04/15/cool-extension-methods-for-idatareader-interface.aspx</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/codeforeternity/technology/~5/y1KOGFf-akA/128.ashx" length="638" type="application/x-zip-compressed" /><feedburner:origEnclosureLink>http://codeforeternity.com/blogs/technology/attachment/128.ashx</feedburner:origEnclosureLink></item></channel></rss>
