<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://weblogs.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" 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/"><channel><title>Patrick Steele&amp;#39;s .NET Blog</title><link>http://weblogs.asp.net/psteele/default.aspx</link><description>Implements ICodeWithDotNet</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Lansing Day of .NET Recap</title><link>http://weblogs.asp.net/psteele/archive/2008/06/23/lansing-day-of-net-recap.aspx</link><pubDate>Tue, 24 Jun 2008 02:25:23 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6313293</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6313293</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/06/23/lansing-day-of-net-recap.aspx#comments</comments><description>&lt;p&gt;I had a great time at the Lansing Day of .NET on Saturday!&amp;nbsp; Not only are people &lt;a href="http://keithelder.net/blog/archive/2008/06/22/Lansing-Day-of-.Net---A-Blast.aspx" target="_blank"&gt;blogging&lt;/a&gt; about &lt;a href="http://joshua-clark.blogspot.com/2008/06/lansing-day-of-net.html" target="_blank"&gt;it&lt;/a&gt;, but it &lt;a href="http://www.wlns.com/global/story.asp?s=8537292" target="_blank"&gt;made the news&lt;/a&gt; too!&amp;nbsp; Awesome job guys.&amp;nbsp; You packed a lot of great stuff in one day.&amp;nbsp; As someone who helped plan the Ann Arbor Day of .NET last year, I know that it takes a lot of time and legwork to put one of those together.&lt;/p&gt; &lt;p&gt;I didn't get there in time to see &lt;a href="http://michaeleatonconsulting.com/blog/" target="_blank"&gt;Michael Eaton's&lt;/a&gt; ActiveRecord talk.&amp;nbsp; But I did catch &lt;a href="http://jrwren.wrenfam.com/blog/" target="_blank"&gt;Jay's&lt;/a&gt; Windsor talk.&amp;nbsp; After lunch, I did my &lt;a href="http://www.castleproject.org/monorail/index.html" target="_blank"&gt;Monorail&lt;/a&gt; presentation.&amp;nbsp; This was an expanded version of my 30-minute Monorail "overview" I gave during a vendor session at &lt;a href="http://www.codemash.org/" target="_blank"&gt;CodeMash&lt;/a&gt; this past January.&amp;nbsp; I took out a couple of the "flashy demos" of scaffolding and AJAX and got a bit more into the details of Monorail.&amp;nbsp; It went pretty well, but after doing a post-mortem (I always jot down notes on how I feel I did), I think I'd do this talk a little differently in the future.&amp;nbsp; Probably a bit more of me actually coding a few controllers and less viewing code "concepts" in Powerpoint.&lt;/p&gt; &lt;p&gt;But the best part was my speaker badge &lt;a href="http://keithelder.net/blog/archive/2008/06/22/Lansing-Day-of-.Net---A-Blast.aspx" target="_blank"&gt;signed by The Elder&lt;/a&gt; himself!&amp;nbsp; I will cherish it for years to come.&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.lotsofemail.com/blog_images/LansingDayof.NETRecap_13B4B/ElderSig.jpg" target="_blank"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="185" alt="ElderSig" src="http://www.lotsofemail.com/blog_images/LansingDayof.NETRecap_13B4B/ElderSig_thumb.jpg" width="244" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6313293" width="1" height="1"&gt;</description></item><item><title>Speaking at Lansing Day of .NET</title><link>http://weblogs.asp.net/psteele/archive/2008/05/28/speaking-at-lansing-day-of-net.aspx</link><pubDate>Thu, 29 May 2008 02:42:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6227611</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6227611</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/05/28/speaking-at-lansing-day-of-net.aspx#comments</comments><description>&lt;p&gt;I got an email last week informing me that my &lt;a href="http://www.castleproject.org/monorail/index.html" target="_blank"&gt;Monorail&lt;/a&gt; talk has been accepted for &lt;a href="http://www.dayofdotnet.org/Lansing/2008/Default.aspx" target="_blank"&gt;Lansing's Day of .NET&lt;/a&gt; on June 21st.&amp;nbsp; Woo Hoo!!&amp;nbsp; If you check out the &lt;a href="http://www.dayofdotnet.org/Lansing/2008/Sessions.aspx" target="_blank"&gt;session list&lt;/a&gt;, you'll see that &lt;a href="http://mjeaton.net/" target="_blank"&gt;Michael Eaton&lt;/a&gt; will be presenting an &lt;a href="http://www.castleproject.org/activerecord/index.html" target="_blank"&gt;ActiveRecord&lt;/a&gt; session and &lt;a href="http://jrwren.wrenfam.com/blog/" target="_blank"&gt;Jay Wren&lt;/a&gt; will be using &lt;a href="http://www.castleproject.org/container/index.html" target="_blank"&gt;Windsor Container&lt;/a&gt; for is IoC talk.&amp;nbsp; We've got just about the whole &lt;a href="http://www.castleproject.org/" target="_blank"&gt;Castle Project&lt;/a&gt; stack covered -- in one day!&amp;nbsp; And the event is totally free!&amp;nbsp; Don't miss it!&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.dayofdotnet.org/Lansing/" target="_blank"&gt;&lt;img alt="Lansing Day of .Net, 21 June 2008 - I'll be there!" src="http://www.dayofdotnet.org/Lansing/2008/images/ldodn-160x100inv.png" border="0"&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6227611" width="1" height="1"&gt;</description></item><item><title>Ann Arbor GiveCamp</title><link>http://weblogs.asp.net/psteele/archive/2008/05/23/ann-arbor-givecamp.aspx</link><pubDate>Fri, 23 May 2008 21:27:12 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6215058</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6215058</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/05/23/ann-arbor-givecamp.aspx#comments</comments><description>&lt;p&gt;I'm proud to announce that we've now got a website for the &lt;a href="http://www.annarborgivecamp.org/" target="_blank"&gt;Ann Arbor Give Camp&lt;/a&gt;.&amp;nbsp; This is a great opportunity for local developers to give back to the local community.&amp;nbsp; The &lt;a href="http://www.annarborgivecamp.org/" target="_blank"&gt;website&lt;/a&gt; has all the details but here it is in a nutshell: Local charities gives us a brief overview of some development-related task they need help with (building a new website, updating an existing website, a small data collection app, etc...).&amp;nbsp; We take a bunch of local developers that have volunteered their time for a weekend and we get stuff done!&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.wearemicrosoft.com/WAM/Home.aspx" target="_blank"&gt;Dallas&lt;/a&gt; and &lt;a href="http://coders4charities.org/" target="_blank"&gt;Kansas City&lt;/a&gt; have recently done &lt;a href="http://givecamp.org/" target="_blank"&gt;Give Camps&lt;/a&gt; and they've gone over very well.&amp;nbsp; We've got a great set of folks to help organize this event: Microsoft's &lt;a href="http://blogs.msdn.com/jennifer/default.aspx" target="_blank"&gt;Jennifer Marsman&lt;/a&gt;, &lt;a href="http://srtsolutions.com/blogs/billwagner/" target="_blank"&gt;Bill Wagner&lt;/a&gt;, myself, &lt;a href="http://www.dotnetrockstar.com/index.html" target="_blank"&gt;John Hopkins&lt;/a&gt; and many others.&amp;nbsp; Our timeframe is pretty short, but we've already gotten a ton of interest from local developers when we've mentioned this at user group meetings.&lt;/p&gt; &lt;p&gt;If you want to help out as a developer, go &lt;a href="http://www.annarborgivecamp.org/DevRegister.aspx" target="_blank"&gt;register at the site&lt;/a&gt;.&amp;nbsp; We're looking for all types of people -- PHP, Ruby, MySql, .NET, Sql Server, Web -- not just .NET developers.&amp;nbsp; We'll be holding the event at &lt;a href="http://www.wccnet.edu/" target="_blank"&gt;Washtenaw Community College&lt;/a&gt; on July 11th, 12th and 13th.&amp;nbsp; WCC is a great venue.&amp;nbsp; We've held a number of Day of .NET events there in the past and have been very happy with them.&amp;nbsp; And to show just how great WCC, &lt;strong&gt;&lt;em&gt;they've donated the space and internet access for this event!&lt;/em&gt;&lt;/strong&gt;&amp;nbsp; Awesome!&lt;/p&gt; &lt;p&gt;If you know of any charities that need help, &lt;a href="http://www.annarborgivecamp.org" target="_blank"&gt;send them over to the site&lt;/a&gt;.&amp;nbsp; Verio has already committed to providing &lt;strong&gt;free webhosting for two (2) years&lt;/strong&gt; to any charity that we help out during the Give Camp!&lt;/p&gt; &lt;p&gt;If you have any questions, &lt;a href="http://weblogs.asp.net/psteele/contact.aspx" target="_blank"&gt;drop me an email&lt;/a&gt; or check out the &lt;a href="http://www.annarborgivecamp.org" target="_blank"&gt;website&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6215058" width="1" height="1"&gt;</description></item><item><title>Come to GANG next week!</title><link>http://weblogs.asp.net/psteele/archive/2008/05/16/come-to-gang-next-week.aspx</link><pubDate>Fri, 16 May 2008 12:53:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6195592</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6195592</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/05/16/come-to-gang-next-week.aspx#comments</comments><description>&lt;p&gt;Next week, our local user group (&lt;a href="http://www.migang.org/" target="_blank"&gt;GANG&lt;/a&gt;) is having Jason Beres -- INETA Speaker and Director of Product Management for Infragistics -- come and talk about building applications with Silverlight 2.0.&amp;nbsp; I'm really looking forward to this one since I haven't had time to dive into Silverlight myself.&amp;nbsp; Come on down to &lt;a href="http://www.microsoft.com/about/companyinformation/usaoffices/heartland/southfield.mspx" target="_blank"&gt;Microsoft's Southfield, Michigan offices&lt;/a&gt; on Wednesday, May 21st at 6:30pm.&lt;/p&gt; &lt;p&gt;PS: Sorry about the &lt;a href="http://www.migang.org/" target="_blank"&gt;GANG website&lt;/a&gt; -- it's a little plain right now.&amp;nbsp; We're in the middle of re-working the website and should have the new one up before next weeks meeting.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6195592" width="1" height="1"&gt;</description></item><item><title>The Elder will be back!</title><link>http://weblogs.asp.net/psteele/archive/2008/05/14/the-elder-will-be-back.aspx</link><pubDate>Wed, 14 May 2008 16:41:04 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6189042</guid><dc:creator>PSteele</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6189042</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/05/14/the-elder-will-be-back.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://keithelder.net/blog/Default.aspx" target="_blank"&gt;Keith Elder&lt;/a&gt; will be &lt;a href="http://feeds.feedburner.com/~r/keithelder/~3/287527204/Speaking-at-Lansing-MI-Day-of-.Net-Thanks-To-Passing.aspx" target="_blank"&gt;back in Michigan&lt;/a&gt; next month for the &lt;a href="http://www.dayofdotnet.org/" target="_blank"&gt;Lansing Day of .NET&lt;/a&gt;!&amp;nbsp; This is great news.&amp;nbsp; Keith is a great presenter and is always entertaining and informative.&amp;nbsp; I've submitted a couple of abstracts myself.&amp;nbsp; Even if I don't present, I'll still be there.&lt;/p&gt; &lt;p&gt;Keep watching &lt;a href="http://www.dayofdotnet.org/" target="_blank"&gt;the site&lt;/a&gt; to see what other great speaker speakers will be sharing their expertise at this FREE all-day event.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6189042" width="1" height="1"&gt;</description></item><item><title>Lazy Loading/Eager Loading</title><link>http://weblogs.asp.net/psteele/archive/2008/05/07/lazy-loading-eager-loading.aspx</link><pubDate>Wed, 07 May 2008 14:00:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6165581</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6165581</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/05/07/lazy-loading-eager-loading.aspx#comments</comments><description>&lt;p&gt;The &lt;a href="http://blogs.hibernatingrhinos.com/nhibernate/Default.aspx" target="_blank"&gt;NHibernate FAQ&lt;/a&gt; has a &lt;a href="http://blogs.hibernatingrhinos.com/nhibernate/archive/2008/05/06/loading-a-complex-object-graph.aspx" target="_blank"&gt;new post&lt;/a&gt; about complex object graphs and lazy loading.&amp;nbsp; If you use &lt;a href="http://www.nhibernate.org/" target="_blank"&gt;NHibernate&lt;/a&gt; (or, &lt;a href="http://www.castleproject.org/activerecord/index.html" target="_blank"&gt;ActiveRecord&lt;/a&gt; -- which makes NHibernate a whole lot easier), it's worth a look.&amp;nbsp; The technique described can greatly improve the way your app interacts with the database.&amp;nbsp; &lt;a href="http://en.wikipedia.org/wiki/Object-relational_mapping" target="_blank"&gt;OR mappers&lt;/a&gt; are nice, but you need to make sure you understand what is happening with the database calls that are made automatically by your OR framework.&lt;/p&gt; &lt;p&gt;If you're using &lt;a href="http://www.castleproject.org/activerecord/index.html" target="_blank"&gt;ActiveRecord&lt;/a&gt;, here's a few more items regarding lazy loading:&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.castleproject.org/activerecord/documentation/v1rc1/usersguide/lazy.html" target="_blank"&gt;Enabling Lazy Loading in ActiveRecord&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.castleproject.org/activerecord/documentation/trunk/advanced/tuning.html" target="_blank"&gt;Tuning ActiveRecord&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;a href="http://www.ayende.com/Blog/archive/7627.aspx" target="_blank"&gt;Combating the Select N + 1 Problem In NHibernate&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6165581" width="1" height="1"&gt;</description></item><item><title>Navigating around in the VS.NET IDE</title><link>http://weblogs.asp.net/psteele/archive/2008/05/05/navigating-around-in-the-vs-net-ide.aspx</link><pubDate>Mon, 05 May 2008 14:58:46 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6159597</guid><dc:creator>PSteele</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6159597</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/05/05/navigating-around-in-the-vs-net-ide.aspx#comments</comments><description>&lt;p&gt;Last week, &lt;a href="http://srtsolutions.com/blogs/billwagner" target="_blank"&gt;Bill Wagner&lt;/a&gt; and I were providing some C# training for one of our clients.&amp;nbsp; Bill showed the class how to use F12 to jump to the definition of a method.&amp;nbsp; One of the students asked how to go back to your previous position and Bill didn't know the key binding off hand.&lt;/p&gt; &lt;p&gt;As someone who comes from a VB6 background, I've maintained my VB6 keyboard mappings since I moved to C# in 2003.&amp;nbsp; Navigating around inside the VS.NET IDE has been a no-brainer for me since all of the keystrokes I used for the 7 or 8 years of VB development are the same in VS.NET -- assuming you use the VB6 keyboard layout.&lt;/p&gt; &lt;p&gt;I decided to see if C# has a default key binding to jump back to your previous positions after jumping to a method definition using F12.&amp;nbsp; First off, I wanted to see what IDE command is mapped to my "go back" function.&amp;nbsp; I pulled up the VS.NET IDE keyboard options, clicked on the "Press shortcut keys" texbox and hit the keyboard keystroke I use for jumping back to my previous position (Ctrl+Shift+F2):&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="386" alt="image" src="http://www.lotsofemail.com/blog_images/NavigatingaroundintheVS.NETIDE_9A61/image.png" width="648" border="0"&gt; &lt;/p&gt; &lt;p&gt;Looking in the "Shortcut currently used by" field, I see "View.NavigateBackward" is the command used in the IDE to navigate back to your previous position.&amp;nbsp; Now I changed my keyboard mapping scheme to C# and entered "View.NavigateBackward" into the "Show commands containing" field:&lt;/p&gt; &lt;p&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="386" alt="image" src="http://www.lotsofemail.com/blog_images/NavigatingaroundintheVS.NETIDE_9A61/image_3.png" width="648" border="0"&gt; &lt;/p&gt; &lt;p&gt;So I see control and "-" (minus) is the keystroke to jump back in C#.&amp;nbsp; I changed my IDE settings to use C# and tested this out.&amp;nbsp; Sure enough, I can use F12 to jump to a method definition and then ctrl+- to return to my previous position -- sort of like having my own little callstack within the IDE.&amp;nbsp; :)&lt;/p&gt; &lt;p&gt;And now I've changed my settings back to VB6 mapping scheme since I'm a creature of habit!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6159597" width="1" height="1"&gt;</description></item><item><title>LINQ: Deferred Execution</title><link>http://weblogs.asp.net/psteele/archive/2008/04/18/linq-deferred-execution.aspx</link><pubDate>Fri, 18 Apr 2008 18:22:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6110559</guid><dc:creator>PSteele</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6110559</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/18/linq-deferred-execution.aspx#comments</comments><description>&lt;p&gt;Another interesting tidbit I learned about at the summit was deferred execution of LINQ queries.&lt;/p&gt; &lt;p&gt;Here's an example that highlights what deferred execution means to you.&amp;nbsp;&amp;nbsp; Let's create a Customer class and then build up a list of customers:&lt;/p&gt; &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 113px; background-color: #f4f4f4; max-height: 200px"&gt; &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Customer&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ID { get; set; }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name { get; set; }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; Balance { get; set; }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 162px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; List&amp;lt;Customer&amp;gt; GetCustomers()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Customer&amp;gt;()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Customer {ID = 1, Name=&lt;span style="color: #006080"&gt;"Bill"&lt;/span&gt;, Balance = 22.50},&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Customer {ID = 2, Name=&lt;span style="color: #006080"&gt;"Bob"&lt;/span&gt;, Balance = 0.00},&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Customer {ID = 3, Name=&lt;span style="color: #006080"&gt;"Joe"&lt;/span&gt;, Balance = -5.00}&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     };&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now assume we're going to run a query to find all Customers whose first name begins with a particular letter (supplied in a variable):&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 211px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; var customers = GetCustomers();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; firstLetter = &lt;span style="color: #006080"&gt;"B"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; var query = from c &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; customers&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; c.Name.StartsWith(firstLetter)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;             select c;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt; firstLetter = &lt;span style="color: #006080"&gt;"J"&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Customer c &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; query)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     Console.WriteLine(c.Name);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;What do you think prints out?&amp;nbsp; Due to deferred execution, the application will only print "Joe", not "Bill" and "Bob" as you might expect.&lt;/p&gt;
&lt;p&gt;The code executed in line 4 only builds the query into a query expression tree.&amp;nbsp; And that expression tree includes a reference to the "firstLetter" variable, not its contents.&amp;nbsp; The expression tree is not executed until line 9 when a foreach loop is used.&amp;nbsp; As a result, the value of the "firstLetter" variable is not obtained until line 9.&lt;/p&gt;
&lt;p&gt;So be careful how you use locally-scoped variables in your LINQ queries and be aware of deferred execution in LINQ queries.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6110559" width="1" height="1"&gt;</description></item><item><title>Extension Methods: Behind the scenes</title><link>http://weblogs.asp.net/psteele/archive/2008/04/18/extension-methods-behind-the-scenes.aspx</link><pubDate>Fri, 18 Apr 2008 18:21:19 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6110555</guid><dc:creator>PSteele</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6110555</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/18/extension-methods-behind-the-scenes.aspx#comments</comments><description>&lt;p&gt;One of the sessions I was able to attend (and talk about) at the MVP Summit involved some of the new features of C# 3.0.&amp;nbsp; My day job still has me doing a lot of C# 2.0 stuff so I haven't dived in too deeply to the new 3.0 stuff.&amp;nbsp; This was my opportunity to get the information directly from the C# language PM &lt;a href="http://blogs.msdn.com/madst/" target="_blank"&gt;Mads Torgersen&lt;/a&gt;.&amp;nbsp; One thing I found interesting was how extension methods were implemented.&lt;/p&gt; &lt;p&gt;If you're not familiar with extension methods, here they are in a nutshell (and simplified): Extension methods allow you to add new methods to existing classes -- classes that you don't have source code access to and can't recompile with the new method.&amp;nbsp; In reality, you're not truly adding new methods, but the IDE experience makes it look that way so it flows very nicely.&lt;/p&gt; &lt;p&gt;First, let's look at how we'd tackle a problem without extension methods.&amp;nbsp; We have a simple Customer class.&amp;nbsp; I've used C# 3.0's auto-properties to allow me to quickly define the class:&lt;/p&gt; &lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 115px; background-color: #f4f4f4; max-height: 200px"&gt; &lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Customer&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; ID { get; set; }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Name { get; set; }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;double&lt;/span&gt; Balance { get; set; }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Now let's create a list of customers since we're going to iterate over them later:&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 167px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; List&amp;lt;Customer&amp;gt; GetCustomers()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; List&amp;lt;Customer&amp;gt;()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Customer {ID = 1, Name=&lt;span style="color: #006080"&gt;"Bill"&lt;/span&gt;, Balance = 22.50},&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Customer {ID = 2, Name=&lt;span style="color: #006080"&gt;"Bob"&lt;/span&gt;, Balance = 0.00},&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Customer {ID = 3, Name=&lt;span style="color: #006080"&gt;"Joe"&lt;/span&gt;, Balance = -5.00}&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;     };&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that in the GetCustomers code above I'm utilizing C# 3.0 property initializers too to make this demo simple and concise.&lt;/p&gt;
&lt;p&gt;Now we get to the meat of the problem.&amp;nbsp; First off, we're assuming that the Customer class is in another DLL that we don't have source code for it.&amp;nbsp; We'd like to know which customer's are delinquent, i.e. a balance less than zero.&amp;nbsp; It would be easy to simply loop through and check the Balance property, but we'd need that check everywhere we look for a delinquent customer (reports, inquiries, lookups, etc...).&amp;nbsp; And what if our client decided to change the definition of "delinquent" (for example "a balance less than -10.00)?&amp;nbsp; We'd have to change that balance check everywhere.&amp;nbsp; Instead, we'll create a utility method for this (since we can't simply add it to the Customer class):&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 133px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MyExtensions&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsDelinquent1(Customer c)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; c.Balance &amp;lt; 0;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;(You'll see why I called it "IsDelinquent1" and not simply "IsDelinquent" shortly).&amp;nbsp; We created a static class and created a utility method that will tell us if a customer is "delinquent" (based on our client's current definition).&amp;nbsp; Now let's do a quick check to find delinquent customers:&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 210px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Method1()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     var customers = GetCustomers();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Customer c &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; customers)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (MyExtensions.IsDelinquent1(c))&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;             Console.WriteLine(c.Name);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Pretty simple.&amp;nbsp; However, it is a little verbose.&amp;nbsp; Let's now look at how we can utilize extension methods to make this cleaner.&lt;/p&gt;
&lt;p&gt;We go back to our static "MyExtensions" class and add our extension method.&amp;nbsp; It's important to note that extension methods can only be defined in static classes that are contained directly in a namespace (i.e. not a nested class).&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 81px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; IsDelinquent2(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt; Customer c)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; c.Balance &amp;lt; 0;&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;This looks almost &lt;strong&gt;exactly&lt;/strong&gt; like the first method (the code block is identical).&amp;nbsp; We've simply added the "this" keyword at the beginning of the parameter list (before the "Customer" reference).&amp;nbsp; This tells the C# compiler (and the VS.NET IDE) that "IsDelinquent2" is an extension method on "Customer" since it appears right before a Customer parameter.&amp;nbsp; That's the only difference!&lt;/p&gt;
&lt;p&gt;Utilizing this extension method makes the loop code much cleaner and easier to read:&lt;/p&gt;
&lt;div style="border-right: gray 1px solid; padding-right: 4px; border-top: gray 1px solid; padding-left: 4px; font-size: 8pt; padding-bottom: 4px; margin: 20px 0px 10px; overflow: auto; border-left: gray 1px solid; width: 97.5%; cursor: text; line-height: 12pt; padding-top: 4px; border-bottom: gray 1px solid; font-family: consolas, 'Courier New', courier, monospace; height: 211px; background-color: #f4f4f4; max-height: 200px"&gt;
&lt;div style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Method2()&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     var customers = GetCustomers();&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;foreach&lt;/span&gt; (Customer c &lt;span style="color: #0000ff"&gt;in&lt;/span&gt; customers)&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (c.IsDelinquent2())&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         {&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;             Console.WriteLine(c.Name);&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;         }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: white; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; padding-top: 0px; font-family: consolas, 'Courier New', courier, monospace; border-right-style: none; border-left-style: none; background-color: #f4f4f4; border-bottom-style: none"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Very nice!&lt;/p&gt;
&lt;p&gt;Now the reason I've got static code all over this demo is because you can take all of the code, slap it into a VS2008 Console application and compile it (make sure the MyExtensions class is not nested within the default "Program" class).&amp;nbsp; Now fire up ILDASM and look at the decompiled IL for both "Method1" and "Method2" (I named them differently so you could compile them together and examine the differences).&amp;nbsp; You'll see that the IL code is &lt;strong&gt;exactly the same&lt;/strong&gt;, byte for byte.&amp;nbsp; That's because extension methods are not a CLR addition, they are a C# addition.&amp;nbsp; They're a neat "macro" that the C# compiler automatically does for you.&lt;/p&gt;
&lt;p&gt;It's a pretty neat implementation and can make interaction with external libraries a bit easier.&amp;nbsp; And if you're wondering, yes, the extension methods are listed as a method directly on the class with Intellisense.&amp;nbsp; They get a slightly different icon (I wasn't able to capture it with my screen capture utility) and the tooltip for the method in Intellisense has "(extension)" at the beginning of the method name.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6110555" width="1" height="1"&gt;</description></item><item><title>Adding Action Filters to MonoRail Controllers</title><link>http://weblogs.asp.net/psteele/archive/2008/04/15/adding-action-filters-to-monorail-controllers.aspx</link><pubDate>Tue, 15 Apr 2008 22:51:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6102612</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://randomcode.net.nz" mce_href="http://randomcode.net.nz" target="_blank"&gt;Neal Blomfield&lt;/a&gt; made interesting use of MonoRail filters.&amp;nbsp; &lt;a href="http://randomcode.net.nz/2008/03/03/adding-action-filters-to-monorail-controllers/" mce_href="http://randomcode.net.nz/2008/03/03/adding-action-filters-to-monorail-controllers/" target="_blank"&gt;Check it out&lt;/a&gt;.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Filters are commonly used for tasks like authentication and localisation, however by default they run for all actions in the controller and you must specify which actions to exclude using the &lt;code&gt;[SkipFilter]&lt;/code&gt; attribute. In a majority of cases this works well as the filter is designed to handle cross-cutting concerns (which by definition affect most if not all actions), however there are times when you want to apply the filter to a minority of the actions in a controller, or add action specific metadata that may vary the way the filter executes depending on the action. Recently I came across just such a scenario…&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6102612" width="1" height="1"&gt;</description></item><item><title>Sessionless MonoRail Controllers</title><link>http://weblogs.asp.net/psteele/archive/2008/04/15/sessionless-monorail-controllers.aspx</link><pubDate>Tue, 15 Apr 2008 22:40:50 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6102603</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6102603</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/15/sessionless-monorail-controllers.aspx#comments</comments><description>&lt;p&gt;I saw this post on the &lt;a href="http://www.castleproject.org/community/mailinglists.html" target="_blank"&gt;Castle Users mailing list&lt;/a&gt; and thought it was interesting and I wanted to post it.&lt;/p&gt; &lt;p&gt;By default, &lt;a href="http://www.castleproject.org/monorail/index.html" target="_blank"&gt;MonoRail&lt;/a&gt; controllers assume that ASP.NET session state is enabled.&amp;nbsp; If you disable ASP.NET's session state inside web.config, you'll get an exception when &lt;a href="http://www.castleproject.org/monorail/index.html" target="_blank"&gt;MonoRail&lt;/a&gt; tries to process the request.&amp;nbsp; What you need to do in this situation is to add a ControllerDetails attribute to your controller and set "Sessionless = true".&amp;nbsp; Thanks to Roelof Blom for posting a quick solution.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6102603" width="1" height="1"&gt;</description></item><item><title>MVP Summit 2008</title><link>http://weblogs.asp.net/psteele/archive/2008/04/14/mvp-summit-2008.aspx</link><pubDate>Mon, 14 Apr 2008 17:50:30 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6097891</guid><dc:creator>PSteele</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6097891</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/14/mvp-summit-2008.aspx#comments</comments><description>&lt;p&gt;I'm now at the MVP Summit in Seattle.&amp;nbsp; This is my first summit in 5 years and I'm pretty excited!&amp;nbsp; They've got a great line-up of sessions, speakers and events.&amp;nbsp; It'll be a busy four days.&amp;nbsp; I'll try and blog as much as I can (anything that isn't NDA).&amp;nbsp; As a fan of the &lt;a href="http://www.castleproject.org/" target="_blank"&gt;Castle Project&lt;/a&gt; (especially &lt;a href="http://www.castleproject.org/monorail/index.html" target="_blank"&gt;MonoRail&lt;/a&gt;), I'm looking forward to some of the ASP.NET MVC sessios.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6097891" width="1" height="1"&gt;</description></item><item><title>NHibernate 2.0 Statistics and a MonoRail filter</title><link>http://weblogs.asp.net/psteele/archive/2008/04/08/nhibernate-2-0-statistics-and-a-monorail-filter.aspx</link><pubDate>Wed, 09 Apr 2008 01:57:49 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6076559</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6076559</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/08/nhibernate-2-0-statistics-and-a-monorail-filter.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.codinginstinct.com/2008/04/nhibernate-20-statistics-and-monorail.html" target="_blank"&gt;This&lt;/a&gt; looked pretty cool.&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Just to try this out I created a MonoRail filter that checks for "nhibstats" in the query parameters of the request. If the parameter is found it will turn on the nhibernate statistics, this is done before the controller action is executed. After the action as completed it will add the stats data to the PropertyBag so the view can access it.&lt;/p&gt;&lt;/blockquote&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6076559" width="1" height="1"&gt;</description></item><item><title>Home Appliance Repair</title><link>http://weblogs.asp.net/psteele/archive/2008/04/08/home-appliance-repair.aspx</link><pubDate>Tue, 08 Apr 2008 13:52:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6074795</guid><dc:creator>PSteele</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6074795</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/08/home-appliance-repair.aspx#comments</comments><description>&lt;p&gt;Last night, instead of finalizing an app I'm working on for a client, I was playing around with my dishwasher.&amp;nbsp; I'm going to be at the MVP Summit next week and did &lt;strong&gt;NOT&lt;/strong&gt; want to leave my wife alone with the kids and no working dishwasher!&amp;nbsp; It reminded me of my experience a couple of years ago when I had a furnace that didn't want to work.&lt;/p&gt; &lt;p&gt;A furnace (a gas one as we have) seems like such a simple thing: The termostat tells the furnace the house is too cold and the furnace turns on to blow hot air through the house.&amp;nbsp; Once the house is warm enough, the thermostat tells the furnace to turn off.&amp;nbsp; I'm sure many of our clients think the software we bulid is a pretty simple process: Enter a few numbers, drag a few sliders, hit "Submit" and you get your data plotted in a nic pie chart.&amp;nbsp; Easy!&amp;nbsp; But just as we developers put in so much work "behind the scenese" (input validation, unit tests, parameter validation, etc...) so too, do gas furnaces.&lt;/p&gt; &lt;p&gt;Our furnace (like many other gas furnaces, I suspect) has quite a complex cycle between the thermostat saying "I need heat" and actually getting heat.&amp;nbsp; First off, the blower spins up.&amp;nbsp; Time for hot air?&amp;nbsp; Not yet.&amp;nbsp; First, the gas has to flow and something has to ignite it.&amp;nbsp; Our system is pilot-less so there's a heater element.&amp;nbsp; This device is basically a 2-inch piece of material that glows red-hot when the system tells it to.&amp;nbsp; That is actually the second step in the process.&lt;/p&gt; &lt;p&gt;Now the gas flows right?&amp;nbsp; Nope.&amp;nbsp; Before the gas flows, the system must ensure that the heater element is hot enough to ignite the gas.&amp;nbsp; If the heater element was broken and the gas started flowing, instead of heating the house you'd be pumping gas throughout the house.&amp;nbsp; Not good!&amp;nbsp; So there's a heat sensor placed near the heating element.&amp;nbsp; The system tells the heating element to "glow hot".&amp;nbsp; It then waits for the heat sensor to detect that the heating element has gotten hot enough to light the gas.&amp;nbsp; Once this happens, then the system opens the gas flow, the gas ignites and we have hot air to warm up the house.&lt;/p&gt; &lt;p&gt;Not as simple as I had originally thought, but as I learned this, I definitely saw the parallels in my day job of software development.&amp;nbsp; Granted, a fault in my system may generate a nasty error message.&amp;nbsp; A fault in the heater could have much more dire consequences!&lt;/p&gt; &lt;p&gt;Oh yeah, the dishwasher?&amp;nbsp; I don't know what went wrong with that.&amp;nbsp; After pulling it out (its an under-the-counter model) and looking around, nothing seemed out of place.&amp;nbsp; So I turned it on and it started working fine (you know -- the client says, if I do "this" it breaks.&amp;nbsp; You do "this" and it works).&amp;nbsp; Before putting it back under the counter I want to run a few more tests before I mark this bug as "could not duplicate"...&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6074795" width="1" height="1"&gt;</description></item><item><title>Hats off to CATS!</title><link>http://weblogs.asp.net/psteele/archive/2008/04/02/hats-off-to-cats.aspx</link><pubDate>Thu, 03 Apr 2008 02:49:50 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6062325</guid><dc:creator>PSteele</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://weblogs.asp.net/psteele/rsscomments.aspx?PostID=6062325</wfw:commentRss><comments>http://weblogs.asp.net/psteele/archive/2008/04/02/hats-off-to-cats.aspx#comments</comments><description>&lt;p&gt;No, not the musical!&lt;/p&gt; &lt;p&gt;My Lenovo (IBM) X60T Tablet started having a problem about a month ago.&amp;nbsp; The bottom two-inches of the LCD display was flickering/smearing/not displaying properly.&amp;nbsp; I noticed that if I gently squeezed one corner of the display, the problem went away but returned within a few days.&amp;nbsp; Further squeezing lasted only a day or two, then hours, then it was flaky all the time.&lt;/p&gt; &lt;p&gt;My warranty expires soon and this seemed like a warranty issue.&amp;nbsp; I did some research and found a local company, &lt;a href="http://www.catscompany.com/" target="_blank"&gt;CATS CO&lt;/a&gt;, that is an authorized Lenovo repair center.&amp;nbsp; I went through the fun of backing up EVERYTHING off the machine.&amp;nbsp; Double-checked my backups, removed the hard drive and took it in for service on Tuesday 3/25 (in the afternoon).&amp;nbsp; They said they'd call in 3 to 4 days with an estimate.&lt;/p&gt; &lt;p&gt;On Monday morning (3/31) I recieved a phone call at 10:00am.&amp;nbsp; My tablet was fixed and ready to be picked up.&amp;nbsp; It was a warranty issue and I owed nothing.&amp;nbsp; Sweet!&amp;nbsp; I was expecting to be without my laptop for at least a week, perhaps a little longer if they needed to order parts.&amp;nbsp; Needless to say, I was very happy with the service I got from CATS CO and would recommend them to anyone in the southeast Michigan area needing to get a laptop repaired.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6062325" width="1" height="1"&gt;</description></item></channel></rss>