<?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>Bill Blogs in C#</title><link>http://srtsolutions.com/blogs/billwagner/default.aspx</link><description>Bill Wagner discusses C#, LINQ, and other items of interest</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/billwagner" type="application/rss+xml" /><item><title>Reflections on Executive Briefing: Natural User Interface and Social Media</title><link>http://feedproxy.google.com/~r/billwagner/~3/TrpFhMxa2A0/reflections-on-executive-briefing-natural-user-interface-and-social-media.aspx</link><pubDate>Thu, 25 Jun 2009 15:56:56 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:11764</guid><dc:creator>wwagner</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=11764</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/06/25/reflections-on-executive-briefing-natural-user-interface-and-social-media.aspx#comments</comments><description>&lt;p&gt;Once again, we brought together a small group to discuss two more upcoming topics for the software industry. This time it was Natural User Interfaces and Social Media.&lt;/p&gt;  &lt;p&gt;The most interesting observation is that there is a bigger gap between the future-oriented Natural User Interfaces and the closer-to-the-mainstream Social Media topic. That colors this post: In this group we had much more discussion on Social Media than we did on Natural User Interfaces. That&amp;#39;s a function of the group, and the relative adoption of both topics.&lt;/p&gt;  &lt;h4&gt;Natural User Interfaces&lt;/h4&gt;  &lt;p&gt;Natural User Interfaces are a rather nascent topic in our industry. However, I do think that over the next decade, it will become more and more important. The mouse and keyboard metaphor is more than 30 years old. Gaming has clearly gone way beyond mouse and keyboard.&amp;#160; (How long would you play rock band or guitar hero using a mouse and keyboard? Flight Simulators, racing games, and more use custom controllers that are supposedly more natural than the mouse and keyboard metaphor we’re forced to use in our regular line of business applications.&lt;/p&gt;  &lt;p&gt;We’re starting to see some more forward looking computing devices.&amp;#160; iPhone, iPods, Zune, Surface and Windows 7 multi-touch are all examples of a more natural user interface. In all cases, we’re using more natural motions to directly work with the device. &lt;/p&gt;  &lt;p&gt;The conversation lagged somewhat. We didn’t have many of the devices at our disposal that day. Also, it was a bit harder to create a dynamic discussion because it was harder to get conversations about how to these new devices might map to what we do.&lt;/p&gt;  &lt;h4&gt;Social Media&lt;/h4&gt;  &lt;p&gt;Social Media was completely different. This was very lively, and it’s clear how we can all make use of social media for our business and personal endeavors. &lt;/p&gt;  &lt;p&gt;The clearest point here is that the twitter model has won. It’s more interesting than Facebook, LinkedIn, or any other social media platform today. &lt;/p&gt;  &lt;p&gt;The reason is that it provides the best way to reach an authentic audience from an authentic perspective. &lt;/p&gt;  &lt;p&gt;Andy Seidl (&lt;a href="http://twitter.com/faseidl" target="_blank"&gt;@faseidl&lt;/a&gt;) has described twitter as ‘a world wide cocktail party’. That’s a very apt description. You can wade in at any time, you can choose to behave like a professional, or be that person in the corner with the lampshade on his head. You can leave conversations that aren’t interesting. But most importantly, you can engage in real conversations with those people with whom you interact. &lt;/p&gt;  &lt;p&gt;That’s the most interesting part: Social Media must be personal in order to be useful. You can only create an audience by engaging in real conversations. Once you engage in real conversations, you can get real results.&lt;/p&gt;  &lt;p&gt;Social Media also allows you to get around the major barriers to efficiency today.&amp;#160; Our corporate structure exists to allow specialization, which builds walls and silos around different areas, business units, and disciplines. With a twitter presence, I’ve found it easier to reach elected officials, vendors, customers, and collaborators. I haven’t used anything else that has made it easier to reach as many people in as many ways.&lt;/p&gt;  &lt;p&gt;Bud Gibson (&lt;a href="http://twitter.com/Innovators" target="_blank"&gt;@Innovators&lt;/a&gt;) has made significant investments in many areas of social media. He’s also claiming that twitter is a better investment than any other social media. In fact, he’s finding that twitter is better than ‘pay for click’ advertising to reach new prospective customers.&amp;#160; It gets back to Andy’s cocktail party analogy: It’s all about the conversation.&lt;/p&gt;  &lt;p&gt;The bulk of this was about Twitter, although we did discuss other media as well. However, most of the other social media create more walls around different communities. They are ways to interact with people you already know. Facebook and LinkedIN are platforms to talk with people you know. Twitter starts a conversation, and as part of the platform, allows anyone to join and participate. &lt;/p&gt;  &lt;h4&gt;Was there a call to action?&lt;/h4&gt;  &lt;p&gt;There was less of a call to action here. NUI seems a bit farther in the future. The call to action was to ‘keep an eye on it’. It likely will be important, but not immediately for broad reach applications. &lt;/p&gt;  &lt;p&gt;For social media, the call to action was to develop a strategy about how to participate. Your customers are participating. Your competitors likely are too. That means you need to participate, and you need to differentiate yourself with your content.&lt;/p&gt;  &lt;p&gt;Oh, and you can follow my updates on twitter as well: &lt;a href="http://twitter.com/billwagner" target="_blank"&gt;@billwagner&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=11764" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/TrpFhMxa2A0" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Me/default.aspx">Me</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/local+interest/default.aspx">local interest</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Software+Engineering/default.aspx">Software Engineering</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/06/25/reflections-on-executive-briefing-natural-user-interface-and-social-media.aspx</feedburner:origLink></item><item><title>Reflections on Executive Briefing Event: Cloud &amp; RIA</title><link>http://feedproxy.google.com/~r/billwagner/~3/_1OMlO9vt4E/reflections-on-executive-briefing-event-cloud-amp-ria.aspx</link><pubDate>Fri, 19 Jun 2009 21:43:22 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:11565</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=11565</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/06/19/reflections-on-executive-briefing-event-cloud-amp-ria.aspx#comments</comments><description>&lt;p&gt;Last Tuesday, we hosted our first executive briefing on upcoming technology trends.&amp;#160; The first two topics were Cloud Computing and Rich Internet Applications (RIA). We chose those topics because examples of RIA applications are already around, and cloud computing is on the horizon. It was a great mix of present and future discussion.&lt;/p&gt;  &lt;p&gt;Nerd Note: My regular readers that are looking for core technology content won’t find it here. Our discussions were on the business issues around these technologies. No code samples here, but there were fantastic architecture and design discussions.&lt;/p&gt;  &lt;h4&gt;Cloud Computing&lt;/h4&gt;  &lt;p&gt;I’ll start by saying that I’m personally excited about Cloud Computing. I’m spending time building applications on Azure and Live Framework. &lt;/p&gt;  &lt;p&gt;The opening discussion centered around separating the buzzword “Cloud Computing” from the substantive advantages of using a cloud platform. The ‘Cloud Computing’ buzzword has been attached to many different activities: Google Docs can be considered cloud computing.&amp;#160; So can LiveMail, GMail, or zune marketplace.&amp;#160; LiveMesh is clearly a cloud based application. However, for most of us in the Software Development community, we think of cloud computing as having our own applications running in the cloud.&amp;#160; That means Windows Azure, Amazon’s Elastic Computing Platform, or the Google App Engine. Even those this was an executive type of briefing, we are all in the software industry. We build things, so we look at tools in terms of what we can build. &lt;/p&gt;  &lt;p&gt;From there, we discussed the risks to moving toward cloud computing. There are many.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Current Investments&lt;/strong&gt;: A lot of the large enterprises already have significant investment in their own DataCenters. This will change the economics of moving to the cloud.&amp;#160; Should an enterprise retire its datacenter? If so, at what cost? Having already spent all the money to build a data center, cloud computing will take much longer to generate ROI.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Sensitive Data&lt;/strong&gt;:&amp;#160; Others have discussed this as well,but the main concern here is fear.&amp;#160; Many companies have entered into a trust relationship with their customers that involves how the vendor handles the customers’ data. Most vendors are concerned with offloading that trust relationship to a 3rd party. Regardless of how much trust they may place in that 3rd part already, they still have concerns. Cloud platforms increase this concern because not only is the data offsite, the data is somewhere unknown.&amp;#160; You know, ‘it’s in the cloud’.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Spotty Connectivity:&lt;/strong&gt;&amp;#160; We developers tend to locate where we have great connectivity.&amp;#160; It’s almost a prerequisite for where we choose to live and work. However, the same isn’t true for all our customers. Some of them still must live in locations where connectivity is not a given. Or, even if there is great connectivity, it may not have high enough uptimes.&lt;/p&gt;  &lt;p&gt;But of course, we are excited about building software for the cloud, so what are the drivers to build software there? We are we excited about cloud computing?&lt;/p&gt;  &lt;p&gt;Once again, there are a lot of great business drivers for cloud computing.&amp;#160; However, almost all of them turn into one statement:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;&lt;em&gt;Cloud Computing is Elastic.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;That implies several drivers for moving applications into the cloud. Economics is the greatest force: Under current models, your data center must be built to handle your peak load. You’ll pay for the infrastructure at all times, even at the minimum load for your application. For applications with seasonal implications (retail, tax applications, Olympics, etc) that can be a huge savings.&lt;/p&gt;  &lt;p&gt;There are other drivers as well.&amp;#160; Scale is a big one.&amp;#160; We work with some researchers that generate terabytes of data every month. That’s an incredible expense, and cloud based computing can lower the storage costs.&lt;/p&gt;  &lt;p&gt;After discussing some of the positives, we did a little comparing on the major announced cloud platforms.&amp;#160; Our index-card sized comparison is this:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Amazon’s Elastic Computing is the most immediate on-ramp to the cloud.&lt;/li&gt;    &lt;li&gt;Google App Engine is a great platform for scripted web applications.&lt;/li&gt;    &lt;li&gt;Windows Azure is a new OS optimized for cloud computing.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here’s why we came to that conclusion:&amp;#160; Amazon’s platform is based on the concept of renting a virtual machine image (either Linux or Windows Server). That makes it the smallest distance from any current application architecture. Google App Engine is optimized for scripting web applications. It’s simple to create web apps there. Windows Azure is setup a bit differently, and enables you to think of an app running ‘in the cloud’ as opposed to running ‘on N servers in the cloud’. That makes it a bit more work to take advantage of the capabilities, but could be a bigger win once there.&lt;/p&gt;  &lt;p&gt;We finished with an interesting question from one of our customers: “Are we recommending cloud computing, and if so, whose cloud?”&lt;/p&gt;  &lt;p&gt;We all weighed in with positive comments.&amp;#160; My own view was that if there weren’t overwhelming negatives (such as resistance to data location), I’ve been recommending cloud based solutions almost exclusively.&amp;#160; Which cloud is trickier. I believe in the Azure vision, because even though you can leverage much of your existing skills, it does make you think about running in a cloud. Therefore, for customers invested in .NET, or open to moving there, it’s my choice. However, it’s not a good idea to recommend porting a large codebase from other platforms (java, php) just to move to Azure.&amp;#160; I know there are some strategies for running those applications in Azure, but I don’t have enough experience there to place big bets on it. And, too many customers with Java or PHP apps have a dependency on MySQL, which doesn’t run in Azure.&amp;#160; When those barriers are in place, Amazon’s Elastic Computing platform makes more sense.&lt;/p&gt;  &lt;p&gt;There’s also a lot of interest from larger companies about running the Azure stack in their own data centers. Interestingly, while I understand some of the justification, I think it’s a short term concern.&amp;#160; Why would you run your own version of the Azure stack instead of pushing your application into the immense scale of a world-wide scale cloud?&lt;/p&gt;  &lt;h4&gt;Rich Internet Applications&lt;/h4&gt;  &lt;p&gt;One great thing about conducting small seminars is that we can set the agenda and veer off that agenda as energy takes us in different directions.&amp;#160; &lt;/p&gt;  &lt;p&gt;On Tuesday we spent more than 3/4 of our time on cloud computing, and finished with a brief look at Rich Internet Applications.&lt;/p&gt;  &lt;p&gt;Or rather, we talked about RunKeeper. (&lt;a href="http://www.runkeeper.com"&gt;www.runkeeper.com&lt;/a&gt;) If you run, and you have an iPhone, this is incredibly cool. Take your iPhone on your run, and it maps the distance, and all elevation changes.&amp;#160; We were discussing things like having it monitor your heartbeat, and monitor your speed (which it may do, I forget which features it does, and which we wished it did). &lt;/p&gt;  &lt;p&gt;This one was a bit less ‘game changing’ than cloud computing.&amp;#160; The overall consensus was that computer users want more. Better interaction, data from any device, and not constrained by the classic browser / forms metaphor.&amp;#160; That means we may be entering a time when browser based applications will be considered ‘legacy applications’ unless they make use of Ajax, Silverlight, Flex or similar tools. It’s fun to develop applications that have different capabilities.&lt;/p&gt;  &lt;h4&gt;Closing&lt;/h4&gt;  &lt;p&gt;This was a wonderful experience. It was fantastic to spend a morning with a tremendous set of brain power, all participating in thoughtful discussions about emerging technologies and how to leverage them to bring more value and more capabilities to our customers.&amp;#160; The best part is that some problems which were considered ‘out of scope’ are suddenly in view.&amp;#160; That’s cool.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=11565" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/_1OMlO9vt4E" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/SRT+Solutions/default.aspx">SRT Solutions</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/local+interest/default.aspx">local interest</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Software+Engineering/default.aspx">Software Engineering</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Azure/default.aspx">Azure</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/06/19/reflections-on-executive-briefing-event-cloud-amp-ria.aspx</feedburner:origLink></item><item><title>Reflections on our Software Development Jam</title><link>http://feedproxy.google.com/~r/billwagner/~3/2V6LFhdR__w/reflections-on-our-software-development-jam.aspx</link><pubDate>Tue, 16 Jun 2009 19:28:24 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:11454</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=11454</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/06/16/reflections-on-our-software-development-jam.aspx#comments</comments><description>&lt;p&gt;Yesterday, we hosted a Software Development Jam at Automation Alley in Troy, MI (North suburbs of Detroit, MI for those readers not in the Michigan area). &lt;/p&gt;  &lt;p&gt;We billed the event as a way for developers to learn something about those software techniques that we are convinced are the important areas of growth in the future. Those areas were modern software engineering techniques (TDD, Continuous Integration, distributed version control), modern .NET (WPF, Silverlight), and modern Java platform tools (Scala, Jython, JRuby). We spent the morning going over some general software techniques, discussing what kinds of apps we’d want to build, what folks wanted to learn, and why. We spent the afternoon building samples and learning from each other.&lt;/p&gt;  &lt;p&gt;The folks that attended were an interesting mix. We had people&amp;#160; with years of mainframe experience, people that had been teaching C++, and folks in the process of transitioning from IT Pro to developer track careers. &lt;/p&gt;  &lt;p&gt;This was the kind of event that wouldn’t have been possible only a few years in the past. The availability of tools, frameworks, and trial editions helped.&amp;#160; &lt;a href="http://srtsolutions.com/blogs/jaywren/default.aspx" target="_blank"&gt;Jay Wren&lt;/a&gt; setup an SVN server in the meeting room on a spare laptop. Then, he helped everyone get access to it. He also setup a CC.NET server so that all the samples were building throughout the day.&amp;#160; That was a fantastic way to show all the attendees the power of these tools.&amp;#160; If anyone got stuck on a sample later, they could do an SVN update and see a working sample. Others could ask them to checkin their failing build and get help from someone that wasn’t stuck at the time.&amp;#160; And the best part was that everyone could do an &amp;quot;SVN update” and get all the samples before leaving. Of course, everyone could see if anyone made mistakes by monitoring the CC.NET homepage on the internal LAN.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://srtsolutions.com/blogs/mikewoelmer/default.aspx" target="_blank"&gt;Mike Woelmer&lt;/a&gt; led a WPF tutorial in the afternoon. He also gave an overview of the differences between WPF and Silverlight. That helped folks understand when to pick one or the other for a new project. I was coding in Mike’s group, helping folks that got stuck.&amp;#160; I also modified the sample so that much of the middle-tier logic used LINQ style syntax rather than the classic imperative style. Later, Mike and I collaborated on an update to a Windows Forms applications that was multithreaded to give folks an idea on how to use multi-threaded concepts in WPF.&lt;/p&gt;  &lt;p&gt;Meanwhile, &lt;a href="http://srtsolutions.com/blogs/diannemarsh/default.aspx" target="_blank"&gt;Dianne Marsh&lt;/a&gt; was working with a different group building some of the &lt;a href="http://codekata.pragprog.com/" target="_blank"&gt;Code Kata&lt;/a&gt; problems in Scala. &lt;/p&gt;  &lt;p&gt;All in all, we all learned quite a bit about how to apply skills used in one environment to another.&amp;#160; Many of the attendees were stretched to apply what they know to new environments. We were all stretched to explain these new environments in a way that would resonate with people coming from a very different perspective. &lt;/p&gt;  &lt;p&gt;We’ll definitely do more of these in the future.&amp;#160; It was a great way to get information in front of a group of developers and understand the challenges many developers face in adopting new technologies in their current environment. That makes in incumbent upon all of us to do a better job of explaining the value proposition of the latest advances in software development.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=11454" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/2V6LFhdR__w" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/SRT+Solutions/default.aspx">SRT Solutions</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Me/default.aspx">Me</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/local+interest/default.aspx">local interest</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Software+Engineering/default.aspx">Software Engineering</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/06/16/reflections-on-our-software-development-jam.aspx</feedburner:origLink></item><item><title>Azure May CTP is out</title><link>http://feedproxy.google.com/~r/billwagner/~3/ksdbkfXThCM/azure-may-ctp-is-out.aspx</link><pubDate>Mon, 01 Jun 2009 18:53:38 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:11199</guid><dc:creator>wwagner</dc:creator><slash:comments>1</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=11199</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/06/01/azure-may-ctp-is-out.aspx#comments</comments><description>&lt;p&gt;And, it’s got support for VS2010 Beta 1.&lt;/p&gt;  &lt;p&gt;This is amazingly cool.&amp;#160; I downloaded and installed the Azure May CTP (both the SDK and the Visual Studio Tools (link &lt;a href="http://www.microsoft.com/downloads/details.aspx?displaylang=en&amp;amp;FamilyID=11b451c4-7a7b-4537-a769-e1d157bad8c6" target="_blank"&gt;here&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;Being that ‘let’s see if we can break this’ kind of person, I ran the same sample in VS2008 and VS2010 on the fabric on my box.&amp;#160; Both ran concurrently without problems.&amp;#160; The developer fabric kept each copy in its own sandbox.&lt;/p&gt;  &lt;p&gt;After you get the Azure toolkit, you can get the samples (separate download for both VS2010 and VS2008) &lt;a href="http://code.msdn.microsoft.com/windowsazuresamples" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=11199" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/ksdbkfXThCM" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Azure/default.aspx">Azure</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/06/01/azure-may-ctp-is-out.aspx</feedburner:origLink></item><item><title>Not so Hidden Gems in VS 2010</title><link>http://feedproxy.google.com/~r/billwagner/~3/82JtU_2hUGw/not-so-hidden-gems-in-vs-2010.aspx</link><pubDate>Tue, 26 May 2009 21:25:05 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:11057</guid><dc:creator>wwagner</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=11057</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/05/26/not-so-hidden-gems-in-vs-2010.aspx#comments</comments><description>&lt;p&gt;I’m just going to assume that all readers of my blog know that Visual Studio 2010 Beta one has been &lt;a href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" target="_blank"&gt;released&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;I’ve been running it almost exclusively since I downloaded and installed it. There’s a lot to like. For this first post, I’m going to limit my discussion to a very small set of IDE features that thrill me in the new release.&lt;/p&gt;  &lt;h3&gt;Tear away editor and tool windows&lt;/h3&gt;  &lt;p&gt;This is a neat feature for single monitor work, but is absolutely wonderful in a multi-monitor scenario.&amp;#160; In VS2010, you can grab the title tab in an editor window (design or code window) and move it out of the VS IDE frame window. It’s wonderful when you’re trying to do some work that requires examining more than one code file at a time. &lt;/p&gt;  &lt;p&gt;The fact is that this feature works for tool windows as well as editor windows.&amp;#160; In my setup, I’ve tried to maximize my main code window in the main monitor.&amp;#160; Properties, Solution Explorer, and the build output windows are on the secondary monitor. I’ll pull editor windows out when I need to see multiple code (or designer) files for a particular task.&lt;/p&gt;  &lt;h3&gt;PascalCased IntelliSense&lt;/h3&gt;  &lt;p&gt;Love this for discovering classes or methods in the .NET Base Class Libraries. Intellisense now picks up targets that contain the words you type, even if they are not at the beginning. For example, if you type ‘enumer’ in a code window, Intellisense will (as always) contain Enumerable. It will also contain IEnumerable, IOrderedEnumerable, and ParallelEnumerable. &lt;/p&gt;  &lt;p&gt;It’s a great way to discover something that might be the solution to your current coding problems.&lt;/p&gt;  &lt;h3&gt;Real TDD Support: Generate From Usage&lt;/h3&gt;  &lt;p&gt;Create From Usage means you can really follow a TDD methodology. You can right test scenarios that describe how you want to use a class. Once you’ve written the test, you have a test that doesn’t compile (like now). Right click on each item with red squiggles and select “Generate”.&amp;#160; Types allow you to generate a new class (quick default), or “Generate Other” which displays a dialog that lets you select a class, interface, enum, or struct. Furthermore, that dialog lets you select the access modifiers on the type, select a destination project (if you have multiple projects in your solution).&amp;#160; You can follow the same workflow to generate methods or properties once you’ve created the types.&lt;/p&gt;  &lt;p&gt;The IDE will create members that throw NotImplementedExceptions, so all your tests will fail. But, isn’t that the point of TDD?&amp;#160; Once you have those failing tests, you have a task list to make them green.&lt;/p&gt;  &lt;p&gt;In future posts, I’ll touch on more of the major features in VS 2010. I wanted to start with these hidden gems because they can be so easily overlooked if you just start using the new version with your old work patterns.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=11057" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/82JtU_2hUGw" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_+General/default.aspx">C# General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/DevCenterPosts/default.aspx">DevCenterPosts</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/05/26/not-so-hidden-gems-in-vs-2010.aspx</feedburner:origLink></item><item><title>Upcoming Event:  MI Software Stimulus Lab</title><link>http://feedproxy.google.com/~r/billwagner/~3/FrhJduK_mNg/upcoming-event-mi-software-stimulus-lab.aspx</link><pubDate>Tue, 19 May 2009 02:27:23 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:10683</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=10683</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/05/18/upcoming-event-mi-software-stimulus-lab.aspx#comments</comments><description>&lt;p&gt;The software industry will be part of the underpinnings for the jobs of the future. (You can read more of my thoughts on the importance of Software to Michigan’s future &lt;a href="http://www.mlive.com/business/ann-arbor/index.ssf/2009/04/bill_wagner_software_is_a_crit.html" target="_blank"&gt;here&lt;/a&gt;).&lt;/p&gt;  &lt;p&gt;We created our company to create great software, and help others to do the same. In the current climate, we are holding a series of low cost labs to help developers learn skills currently in demand. Free scholarships are available for developers currently unemployed and in need of updating their skills.&lt;/p&gt;  &lt;p&gt;The first of these labs will be at Automation Alley on Monday June 15th.&amp;#160; You can read more about the event &lt;a href="http://srtsolutions.com/blogs/pressreleases/archive/2009/05/18/srt-solutions-presents-software-stimulus-lab-to-support-economic-business-growth.aspx" target="_blank"&gt;here&lt;/a&gt;.&amp;#160; You can sign up &lt;a href="http://srtstimulus.eventbrite.com/" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;Please inform other interested developers of the event.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=10683" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/FrhJduK_mNg" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/SRT+Solutions/default.aspx">SRT Solutions</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/upcoming+attractions/default.aspx">upcoming attractions</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/local+interest/default.aspx">local interest</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/05/18/upcoming-event-mi-software-stimulus-lab.aspx</feedburner:origLink></item><item><title>Query Language or Method calls: A matter of taste</title><link>http://feedproxy.google.com/~r/billwagner/~3/7njSAEN0dLM/query-language-or-method-calls-a-matter-of-taste.aspx</link><pubDate>Mon, 11 May 2009 17:54:09 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:10283</guid><dc:creator>wwagner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=10283</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/05/11/query-language-or-method-calls-a-matter-of-taste.aspx#comments</comments><description>&lt;p&gt;My last post (which was too long ago), generated question on whether I prefer the query language or the method notation for LINQ queries. &lt;/p&gt;  &lt;p&gt;The answer is ‘yes’.&amp;#160; &lt;a href="http://msmvps.com/blogs/jon_skeet/archive/2009/01/07/you-don-t-have-to-use-query-expressions-to-use-linq.aspx"&gt;Jon Skeet&lt;/a&gt; mentioned this as well last January, but anything you can do with query syntax can be accomplished with method calls. (&lt;a href="http://www.informit.com/articles/article.aspx?p=1231459" target="_blank"&gt;Item 36&lt;/a&gt; of &lt;a href="http://www.amazon.com/More-Effective-Specific-Software-Development/dp/0321485890" target="_blank"&gt;More Effective C#&lt;/a&gt; discusses is some detail how the query language operators map to method calls.)&lt;/p&gt;  &lt;p&gt;From the standpoint of correctness, you can use either construct with no differences. That means it is a matter of style whether you choose the query expressions or the method calls. &lt;/p&gt;  &lt;p&gt;My own preference is to use the method call syntax for simpler queries, and use the query syntax for more complex query operations.&lt;/p&gt;  &lt;p&gt;For example, I would use the method call syntax below over the query syntax:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;[] numbers = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; var smallNumbers = from n &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; numbers&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt;                    &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; n &amp;lt; 5&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;                    select n;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt; var smallNumbers2 = numbers.Where((n) =&amp;gt; n &amp;lt; 5);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;However, once a query gets sufficiently complex, I believe the query syntax is more readable:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;[] odds = { 1, 3, 5, 7 };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum2"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;[] evens = { 2, 4, 6, 8 };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum3"&gt;   3:&lt;/span&gt; var values = from oddNumber &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; odds&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum4"&gt;   4:&lt;/span&gt;             from evenNumber &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; evens&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum5"&gt;   5:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; oddNumber &amp;gt; evenNumber&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum6"&gt;   6:&lt;/span&gt;             select &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; { oddNumber, evenNumber, &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum7"&gt;   7:&lt;/span&gt;             Sum = oddNumber + evenNumber };&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum8"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum9"&gt;   9:&lt;/span&gt; var values2 = odds.SelectMany(oddNumber =&amp;gt; evens,&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum10"&gt;  10:&lt;/span&gt;     (oddNumber, evenNumber) =&amp;gt;&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; { oddNumber, evenNumber })&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum12"&gt;  12:&lt;/span&gt;     .Where(pair =&amp;gt; pair.oddNumber &amp;gt; pair.evenNumber).&lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum13"&gt;  13:&lt;/span&gt;     Select(pair =&amp;gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; { &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum14"&gt;  14:&lt;/span&gt;         pair.oddNumber, &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum15"&gt;  15:&lt;/span&gt;         pair.evenNumber, &lt;/pre&gt;


    &lt;pre style="border-bottom-style:none;text-align:left;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:&amp;#39;Courier New&amp;#39;, courier, monospace;direction:ltr;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;" id="lnum16"&gt;  16:&lt;/span&gt;         Sum = pair.oddNumber + pair.evenNumber });&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In my opinion, for more complex queries, the query language produces a much more readable construct. However, on simpler queries, the method calls are easier to understand.&lt;/p&gt;

&lt;p&gt;I like Jon’s comment: “next time you’re writing a query expression, take a look at it afterwards – it it’s simple, try writing it without the extra syntactic sugar.” (from the post referenced above).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=10283" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/7njSAEN0dLM" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Effective+C_2300_/default.aspx">Effective C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_+General/default.aspx">C# General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/DevCenterPosts/default.aspx">DevCenterPosts</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/05/11/query-language-or-method-calls-a-matter-of-taste.aspx</feedburner:origLink></item><item><title>Explain from the Questioner’s perspective, not your own</title><link>http://feedproxy.google.com/~r/billwagner/~3/3hOnVpXnDyI/explain-from-the-questioner-s-perspective-not-your-own.aspx</link><pubDate>Fri, 17 Apr 2009 02:57:25 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:8870</guid><dc:creator>wwagner</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=8870</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/04/16/explain-from-the-questioner-s-perspective-not-your-own.aspx#comments</comments><description>&lt;p&gt;I was involved in an interesting discussion about how the C# language has evolved, and how it’s getting harder and harder to teach developers to be proficient in the language with each passing version.&lt;/p&gt;  &lt;p&gt;I think that’s our fault.&lt;/p&gt;  &lt;p&gt;As leaders and experienced C# developers, we too often teach and explain from our perspective: We learned C# 1.0, learned the new features in 2.0. Then, we learned LINQ and the other syntax additions in 3.0. Now, we’re looking at adding the new 4.0 features to our repertoire of techniques. It makes sense to us, because that’s how we learned.&lt;/p&gt;  &lt;p&gt;But we are not them.&lt;/p&gt;  &lt;p&gt;That’s an inefficient way for someone approaching C# now to learn the language. Instead, we should explain these new concepts based on how one should learn now, not how we learned. I wish I could take credit for this amazing insight, but I must credit Bjarne Stroustrup. He wrote an &lt;a href="http://www.ddj.com/cpp/184403651"&gt;essay&lt;/a&gt; for C++ Users Journal back in 1999 asserting that the C++ community must change how they taught developers C++.&amp;#160; Back then, everyone teaching C++ just assumed that every novice C++ developer was a veteran C developer. And that’s how they taught. Stroustrup instead claimed that developers should learn the best C++ idioms, rather than be taught C, then how to move to C++.&lt;/p&gt;  &lt;h2&gt;&lt;/h2&gt;  &lt;h3&gt;Lambda Expressions as Example&lt;/h3&gt;  &lt;p&gt;Explaining Lambda expressions is a great example of what I mean in C# today.&lt;/p&gt;  &lt;p&gt;When I explain lambda expressions to a novice C# developer, I use this example:&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; var someNumbers = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; List&amp;lt;&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;&amp;gt;(Enumerable.Range(-20, 200));&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; someNumbers.RemoveAll(n =&amp;gt; n &amp;gt; 30);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; assertion = someNumbers.TrueForAll(n =&amp;gt; n &amp;lt; 40);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;Line 1 creates a collection with a bunch of numbers.&lt;/p&gt;

&lt;p&gt;Line 2 introduces a lambda. It removes all numbers greater than 30 from the collection. The lambda expression “n =&amp;gt; n &amp;gt; 30” describes the condition for all elements to be removed from the list. A lambda expression is a short hand description of a method: n is the parameter. The expression returns a boolean, the result of the test ‘n &amp;gt; 30’. &lt;/p&gt;

&lt;p&gt;At this point, I’ll often get a few questions:&lt;/p&gt;

&lt;p&gt;‘what type is n&amp;quot;?’&lt;/p&gt;

&lt;p&gt;That’s easy: the compiler infers types for the parameters to lambda expressions. Here, the compiler infers that n must be integer, because the collection someNumbers contains integers.&lt;/p&gt;

&lt;p&gt;‘there’s no return value’&lt;/p&gt;

&lt;p&gt;Yes, I know that’s not a question. But it does express the confusion, and that’s how it’s often stated. I say that the compiler infers the return type. List.RemoveAll() takes a &lt;em&gt;Predicate&amp;lt;T&amp;gt;&lt;/em&gt; as its parameter, and Predicate&amp;lt;T&amp;gt; returns a bool. therefore, the expression ‘n &amp;gt; 30’ must be a boolean expression. To illustrate this, I’ll modify the code to show how the compiler checks the type. The lambda expression ‘n =&amp;gt; n.ToString()’ doesn’t compile, because n.ToString() evaluates to a string, not a boolean. &lt;/p&gt;

&lt;p&gt;Then, I go on to the concept: a lambda expression is a mechanism that enables you to pass code (in the form of a lambda) to another method for execution later. Internally, List.RemoveAll() evaluates the lambda expression parameter for every element in the list. All elements that return true are removed.&lt;/p&gt;

&lt;p&gt;I follow the same process to explain the TrueForAll() method call. &lt;/p&gt;

&lt;h3&gt;Yeah, but what about delegates, anonymous delegates and expression trees?&lt;/h3&gt;

&lt;p&gt;Those of you that are experienced C# developers are probably concerned: I didn’t mention that lambdas are implemented like anonymous delegates. I didn’t drill down further to state that anonymous delegates are just like delegates. &lt;/p&gt;

&lt;p&gt;In short, I didn’t work back from a lambda expression to the equivalent C# 1.0 syntax. But, that’s the point. Unless you have been working with C# since the beginning, those concepts don’t help you. Someone starting to learn C# now doesn’t have that prior knowledge about C# 1.0, or C# 2.0. &lt;/p&gt;

&lt;p&gt;Read my explanations above again.&amp;#160; They don’t dive into great detail about how a lambda expression is interpreted by the compiler. Rather, they give you a good description of how you would write code using lambda expressions, and what they do for you.&lt;/p&gt;

&lt;p&gt;Nothing I said is wrong, but a lot of details are left out.&amp;#160; That’s ok, hiding details helps novices get started.&amp;#160; We can fill in those holes as these new C# developers develop a greater understanding, and want a deeper understanding.&lt;/p&gt;

&lt;p&gt;At that point, they are ready for a different explanation.&lt;/p&gt;

&lt;p&gt;Until then, we are better off explaining concepts using explanations that help them, even if those explanations are different than how we learned.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=8870" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/3hOnVpXnDyI" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_+General/default.aspx">C# General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/DevCenterPosts/default.aspx">DevCenterPosts</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/04/16/explain-from-the-questioner-s-perspective-not-your-own.aspx</feedburner:origLink></item><item><title>Live Framework and custom resource types</title><link>http://feedproxy.google.com/~r/billwagner/~3/y9OFKKh-5vw/live-framework-and-custom-resource-types.aspx</link><pubDate>Fri, 10 Apr 2009 02:13:36 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:7603</guid><dc:creator>wwagner</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=7603</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/04/09/live-framework-and-custom-resource-types.aspx#comments</comments><description>&lt;p&gt;I’ll start this post with a couple caveats. I’m learning the Live Framework SDK, just everyone else. This (and upcoming) blog posts on the Live Framework are based on my initial learning on Live Framework. All the usual disclaimers apply. &lt;/p&gt;  &lt;p&gt;My plan is to work through some of the Live Framework SDK samples. As I’m doing that, my normal work pattern is to take lots of notes on what I’m learning. My blog seems as good a place as any. Unlike posts on technologies where I’ve spent lots of time, I’m a noob on the Live Framework too. But, there’s only one way to learn.&lt;/p&gt;  &lt;h3&gt;The Project Manager Sample&lt;/h3&gt;  &lt;p&gt;I decided to start with the WPF Project Manager sample. It’s a WPF application that lets you create projects. You can add milestones to those projects. Obviously, you can edit both projects and milestones. The projects are stored as MeshObjects. The milestones are stored as DataEntries in the MeshObjects (representing projects).&lt;/p&gt;  &lt;p&gt;This first post is mostly looking at the application, with a small look at the code.&lt;/p&gt;  &lt;p&gt;I ran the code, created a project and some milestones.&amp;#160; Cool enough.&lt;/p&gt;  &lt;p&gt;Then, I went to the developer mesh website, and looked at my mesh desktop. I expected to see new folders, or something that showed the projects and milestones I created. I was surprised that nothing was there. &lt;/p&gt;  &lt;p&gt;The answer was in the code. Remember from my first post on the &lt;a href="http://srtsolutions.com/blogs/billwagner/archive/2009/01/21/first-looks-at-the-live-framework-sdk.aspx"&gt;Live Framework&lt;/a&gt; that the MyPhotos application used resource types of LiveMeshFolder, and LiveMeshFiles. That makes objects that are visible in the mesh, obviously as folders and files.&lt;/p&gt;  &lt;p&gt;This sample uses different resources types. The sample defines a “Project” resource type for the project, and a “Milestone” type for the milestones.&lt;/p&gt;  &lt;p&gt;Both Project and Milestone are C# classes. They are (more or less) POCO objects. They are decorated with the DataContract attribute (and their properties are decorated with the DataMember attribute).&lt;/p&gt;  &lt;p&gt;Here’s the Project type:&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; [DataContract(Namespace = &lt;span style="color:#006080;"&gt;&amp;quot;Microsoft.Samples.Workflow.ProjectManagerWPF&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Project&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// UUID of the parent MeshObject&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;     [DataMember]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; MOID { get; set; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// Title of the milestone (during save/update, this matches MeshObject.Resource.Title, &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// but is stored here when the custom object is databound instead of the resource)&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt;     [DataMember]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Title { get; set; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// Date when project will be started&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  17:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  18:&lt;/span&gt;     [DataMember]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  19:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; DateTime KickOffDate {get; set;}&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  20:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  21:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// Estimated Date for Completion&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  22:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  23:&lt;/span&gt;     [DataMember]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  24:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; DateTime CompletionDate {get; set;}&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  25:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  26:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// Date when project was shipped&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  27:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  28:&lt;/span&gt;     [DataMember]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  29:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; DateTime ShippedDate {get; set;}&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  30:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  31:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// Description of Project&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  32:&lt;/span&gt;     &lt;span style="color:#008000;"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  33:&lt;/span&gt;     [DataMember]&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  34:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; Description {get; set;}&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  35:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Storing and retrieving the Project type from the Mesh is straightforward Live Framework code. Here’s the code to read a project:&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//grab the Project Instance object from the mesh object and populate an instance of our Project Domain Class&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; Library.Project SaveProject = &lt;span style="color:#0000ff;"&gt;this&lt;/span&gt;.ExistingProjectMeshObject.Resource.GetUserData&amp;lt;Library.Project&amp;gt;();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You simply convert the Resource to the POCO type, using the GetUserData&amp;lt;T&amp;gt; method to convert the resource. Cool. Saving it back is just as easy:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; MO = ExistingProjectMeshObject;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; SaveProject = ExistingProjectMeshObject.Resource.GetUserData&amp;lt;Library.Project&amp;gt;();&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; MO.Resource.Title = tbTitle.Text;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//Set the custom attributes of the mesh object to the values from the library/domain class, &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//this will popualte the userfield data with the deserialized content from the Project object created above&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt; MO.Resource.SetUserData&amp;lt;Library.Project&amp;gt;(SaveProject);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//Set the type of the mesh object&amp;#39;s resource to PRoject&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt; MO.Resource.Type = &lt;span style="color:#006080;"&gt;&amp;quot;Project&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt; &lt;span style="color:#008000;"&gt;//Update the object in the cloud.&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt; MO.Update();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The SetUserData&amp;lt;T&amp;gt; call converts the POCO Project object to a mesh resource. Then, you just need to send the data to the cloud.&lt;/p&gt;

&lt;p&gt;Future posts will dive into the code in more detail, and start on some other mesh style programming. Just this little dive makes me think more about what I can build with this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=7603" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/y9OFKKh-5vw" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/.NET+General/default.aspx">.NET General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_+General/default.aspx">C# General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Live+Framework/default.aspx">Live Framework</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/04/09/live-framework-and-custom-resource-types.aspx</feedburner:origLink></item><item><title>Euler Problem 12</title><link>http://feedproxy.google.com/~r/billwagner/~3/hrncd2DNihk/euler-problem-12.aspx</link><pubDate>Mon, 23 Mar 2009 17:18:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:7095</guid><dc:creator>wwagner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=7095</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/03/23/euler-problem-12.aspx#comments</comments><description>&lt;p&gt;It&amp;rsquo;s been a long time since I have worked on any of the Euler problems.&amp;nbsp; I simply haven&amp;rsquo;t had time.&amp;nbsp; Well, it was time to spend a bit of time just exercising the math part of my mind, and solve another problem.&lt;/p&gt;
&lt;p&gt;Problem 12 asks you to find the first triangle number that has more than 500 divisors.&lt;/p&gt;
&lt;p&gt;Like my other C# solutions, it makes sense to decompose this problem into smaller sets. First, figure out how to generate the triangle numbers. Then, figure out the simplest way to determine how many divisors a number has.&lt;/p&gt;
&lt;p&gt;Let&amp;rsquo;s start with the triangle numbers. The nth triangle number is the sum of all natural numbers less than or equal to N. You can think of them like the number of balls in a billiard rack with N rows:&amp;nbsp; 1, (1+2), (1+2+3), (1+2+3+4), or, 1,3,6,10,15&amp;hellip;&lt;/p&gt;
&lt;p&gt;A little bit of math (or a quick search) will tell you that the Nth triangle number is [N * (N+1)]/2.&lt;/p&gt;
&lt;p&gt;Now, all we need to do is compute the total number of divisors for each of these numbers. One simple answer is to take all number less than or equal to the triangle number. Any of those that divide into the triangle number is a divisor. But, that&amp;rsquo;s incredibly inefficient. Instead, you can stop at Sqrt(Number). That will give you exactly 1/2 the number of divisors. For example, if 128 is divisible by 2, you&amp;rsquo;ve found two divisors: 2, and 64. Therefore, this method tells me quickly how many divisors a number has:&lt;/p&gt;
&lt;div&gt;
&lt;div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; CountDivisors(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; n)&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     var divisors = from val &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(1, (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;)Math.Sqrt(n))&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;                    &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; n % val == 0&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;                    select val;&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; divisors.Count()*2;&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This query (written in two parts) finds the answer. Remember that one of the keys to LINQ is deferred execution. Only the triangle numbers up to and including the answer are generated.&amp;nbsp; The entire program runs in a few seconds:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; var triangleNumbers = from n &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(1, 100000)&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt;                       let Value = (n * (n + 1)) / 2&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;                       select &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;                       {&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;                           Number = Value,&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;                           NumDivisors = CountDivisors(Value)&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;                       };&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt; var answer = (from vals &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; triangleNumbers&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:white;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;              &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; vals.NumDivisors &amp;gt; 500&lt;/pre&gt;
&lt;pre style="line-height:12pt;background-color:#f4f4f4;margin:0em;width:100%;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;                   select vals).First();&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It feels good to stretch the math muscles again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=7095" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/hrncd2DNihk" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_+General/default.aspx">C# General</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Euler/default.aspx">Euler</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/03/23/euler-problem-12.aspx</feedburner:origLink></item><item><title>Code and Slides for State of Michigan Developer Briefing</title><link>http://feedproxy.google.com/~r/billwagner/~3/hsZQdrOC0mc/code-and-slides-for-state-of-michigan-developer-briefing.aspx</link><pubDate>Fri, 20 Mar 2009 02:21:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:7021</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=7021</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/03/19/code-and-slides-for-state-of-michigan-developer-briefing.aspx#comments</comments><description>&lt;p&gt;Yesterday, a number of community leaders and Microsoft employees gave a series of presentations for developers working for the State of MI.&lt;/p&gt;
&lt;p&gt;We spent the better part of the day discussing the current and future trends for developers on the .NET framework.&lt;/p&gt;
&lt;p&gt;My talk was on leveraging tools to improve the quality and timeliness of your work.&lt;/p&gt;
&lt;p&gt;You can get the slides &lt;a href="http://srtsolutions.com/Content/StateOfMIDeveloperBriefing.pdf"&gt;here&lt;/a&gt;. And the samples &lt;a href="http://srtsolutions.com/Content/StateofMI.zip"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=7021" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/hsZQdrOC0mc" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/User+Groups/default.aspx">User Groups</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_+General/default.aspx">C# General</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/03/19/code-and-slides-for-state-of-michigan-developer-briefing.aspx</feedburner:origLink></item><item><title>On craft, dogma, pragmatism and better analogies</title><link>http://feedproxy.google.com/~r/billwagner/~3/lyVfBOLcxRM/on-craft-dogma-pragmatism-and-better-analogies.aspx</link><pubDate>Tue, 24 Feb 2009 19:43:05 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:6561</guid><dc:creator>wwagner</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=6561</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/02/24/on-craft-dogma-pragmatism-and-better-analogies.aspx#comments</comments><description>&lt;p&gt;I’m leaping into a lengthy discussion, so I’ll start with the links:&lt;/p&gt;  &lt;p&gt;Steve Smith wrote &lt;a href="http://stevesmithblog.com/blog/craftsmanship-quality-dogma-and-pragmatism/"&gt;this&lt;/a&gt; post discussing the craftmanship vs. pragmatism. &lt;/p&gt;  &lt;p&gt;Corey Haines wrote &lt;a href="http://programmingtour.blogspot.com/2009/02/re-software-craftsmanship-dogma-and.html"&gt;this response&lt;/a&gt; defending the craft movement.&lt;/p&gt;  &lt;p&gt;And Steve responded again &lt;a href="http://stevesmithblog.com/blog/brief-response-to-corey-on-software-craftsmanship/"&gt;with&lt;/a&gt; this real world example.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Disclaimer: I know both Steve Smith and Corey Haines, and I have a lot of respect for both of them. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;There are times when I believe we get off-track by using the wrong words, and the wrong analogies. Or, we point to the wrong evidence from the analogies.&lt;/p&gt;  &lt;p&gt;Corey made the analogy between software and furniture: craftsmen are like the Amish craftsmen, and industrial software developers are like IKEA factories. &lt;/p&gt;  &lt;p&gt;OK, that’s a reasonable start, and it points us to the wrong root diagnosis.&lt;/p&gt;  &lt;p&gt;Instead, let’s look at craftsmen in the construction industry and watch everything they do.&amp;#160; I believe Corey’s analogy only examined the finished product.&lt;/p&gt;  &lt;h3&gt;A brief side trip to real home renovations&lt;/h3&gt;  &lt;p&gt;A few years ago we put an addition on our house. A portion of the house was one story, and a portion was two stories. We built above the portion that was single story and added two bedrooms. &lt;/p&gt;  &lt;p&gt;The final product is high quality, and my wife and I were very happy with the additions.&lt;/p&gt;  &lt;p&gt;During the process, the carpenters built and destroyed several bits of scaffolding to make their lives easier. &lt;/p&gt;  &lt;p&gt;The first task was to remove the old sections of roofing on the one story portion. Some of that contained beams that were holding up the roof on the two story section. It was weeks until all the framing would be done, but something had to be added to hold up the roof. One carpenter spent a half hour putting up some temporary beams. The roof stayed up.&lt;/p&gt;  &lt;p&gt;This kind of temporary scaffolding was repeated several times through the process. One of the last tasks was to cut the doors from the existing second story into the addition. Before that was done, the carpenters built temporary steps to get up into the new section. This needed to last a month or so.&lt;/p&gt;  &lt;p&gt;Temporary planks were laid while the framing was being constructed, before the final floor was laid. &lt;/p&gt;  &lt;p&gt;None of these temporary tasks had the same quality that was evident in the finished product. That goes for both ‘finish features’ and engineering quality. For example, the temporary supports for the second story roof would not have withstood sustained 50 mph winds coming from the east. A real risk, but small. &lt;/p&gt;  &lt;p&gt;In every case, the temporary solution was removed as work progressed to create the real solution.&lt;/p&gt;  &lt;h3&gt;Okay, but that’s not software&lt;/h3&gt;  &lt;p&gt;I believe there is an important analogy for software.&amp;#160; The temporary scaffolding is analogous to technical debt.&amp;#160; There are times when speed is more important than perfect craft.&amp;#160; However, when that happens, you’ll incur technical debt.&amp;#160; &lt;/p&gt;  &lt;p&gt;Steve McConnell has an &lt;a href="http://blogs.construx.com/blogs/stevemcc/archive/2007/11/01/technical-debt-2.aspx"&gt;old post about Technical Debt&lt;/a&gt; that’s very pertinent here. In it, he separates technical debt on a number of variables. Unintentional debt, which you incur due to low quality work is always bad. That’s what Corey is protesting against. It’s insidious because you don’t even realize you’ve incurred unintentional debt.&lt;/p&gt;  &lt;p&gt;Steve Smith is talking more about intentional debt. Here, Steve McConnell points out the difference between long-term and short-term debt: long term is strategic, and short term is tactical. Further, he describes two kinds of short term debt: ‘large chunks’ and ‘small shortcuts’. The large chunks, because of their size, have more scrutiny, and require more justification. The ‘small shortcuts’ are the kinds of quick shortcuts you do when you’re not being careful: not following your own conventions.&lt;/p&gt;  &lt;p&gt;The purpose of this discussion on technical debt is that debt must eventually be retired. The more debt you take on (of any kind), the more cost to retire that debt. Sometimes even large debt is smart: few of us would own a home without some form of mortgage. That kind of debt is like what Smith (using last names to distinguish between Steve Smith and Steve McConnell) is discussing in his second post. The company’s very existence depends on a short release cycle. In those cases, it’s wise to take on a manageable amount of technical debt. &lt;/p&gt;  &lt;p&gt;Focusing on the technical debt (as opposed to craft vs. pragmatism) gets you to look at the issue in a different way. No debt is always the goal; I wish I didn’t have a mortgage payment. But, smart debt is wise (I’m glad my last several years of mortgage payments have been building equity, rather than saving the full cost before buying a house. That’s true even in today’s economy). But, if you take on debt, you must pay it off. You must plan part of the budget for debt servicing. &lt;/p&gt;  &lt;h3&gt;Time for the big finish&lt;/h3&gt;  &lt;p&gt;Going back to the house renovation project, I didn’t like the appearance of the temporary scaffolding.&amp;#160; It looked shoddy. But, I knew it was temporary, and it was the best plan to achieve the final goal. The true craftsman knows when the first effort must be the best, and when the best plan is to make a (temporary) less than optimal choice, incur the debt, and pay it off. To do that properly requires a frank and honest discussion on the tradeoffs, with a real commitment to paying off whatever technical debt is incurred in the process.&lt;/p&gt;  &lt;p&gt;I think too many people espousing the software craftsman mantra have been burned by too many companies that incur technical debt, and refuse to pay it off until it threatens the company’s very existence. I know I’ve been involved in failed ‘legacy’ projects where the entire team couldn’t pay off the incurred debt. That memory colors your goals, and your trust with those leaders that push ‘the business goals’. &lt;/p&gt;  &lt;p&gt;Incurring technical debt (intentionally) is not the same as low-quality work. Advocating against technical debt is not dogma. It’s only when the people asking to incur technical debt and the people advocating against it don’t have a frank discussion on the benefits and costs (both long term and short term) of the decision. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=6561" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/lyVfBOLcxRM" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Software+Engineering/default.aspx">Software Engineering</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/02/24/on-craft-dogma-pragmatism-and-better-analogies.aspx</feedburner:origLink></item><item><title>Looking at Azure</title><link>http://feedproxy.google.com/~r/billwagner/~3/3MUXYTBJwGs/looking-at-azure.aspx</link><pubDate>Sat, 21 Feb 2009 19:11:59 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:6508</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=6508</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/02/21/looking-at-azure.aspx#comments</comments><description>&lt;p&gt;I’m going to build on my tradition of blogging my notes as I explore new toolkits. Just like I did with LINQ, I’ll be posting blog entries about what I’ve learned as I work with the Azure platform.&lt;/p&gt;  &lt;h3&gt;Dissecting HelloFabric&lt;/h3&gt;  &lt;p&gt;I’m skipping the HelloWorld sample because the only thing I learned was that the current Device Fabric is not compatible with the Current Windows 7 beta build. Two different pre-release components, so I’m not too surprised. &lt;/p&gt;  &lt;p&gt;HelloFabric gives a good overview of some of the basic functionality provided by the cloud infrastructure.&amp;#160; When you run the sample, you’ll have see a simple webpage that demonstrates some of the Azure APIs.&lt;/p&gt;  &lt;p&gt;Let’s look at the code first, and then peek at the cloud specific configuration. The first thing you see when you run the application is that it tells you if it is running in the cloud, or on a standard ASP.NET context.&amp;#160; There’s a bit of code in the the page load handler that looks at the ApplicationEnvironment to see where it’s running.&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#008000;"&gt;// Check if we are running in the fabric&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (ApplicationEnvironment.ApplicationModel == ApplicationModel.Cloud)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     Label3.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Running in the fabric.&amp;quot;&lt;/span&gt; ;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (Request.IsSecureConnection)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;         Label2.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Running over a secure connection.&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;         Label2.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Not running over a secure connection. Please see the documentation to test this sample with SSL.&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;     Label3.Text = &lt;span style="color:#006080;"&gt;&amp;quot;Running outside the fabric.&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  17:&lt;/span&gt;     Label2.Text = &lt;span style="color:#006080;"&gt;&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  18:&lt;/span&gt; }                      &lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The next item you’ll see in the page is that the label contains a set of banner text from one of the config files:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; Label1.Text = ApplicationEnvironment.Settings[&lt;span style="color:#006080;"&gt;&amp;quot;BannerText&amp;quot;&lt;/span&gt;];&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;A little further down the page, you’ll see that you can enter a message that will get written to the log. The code couldn’t be much simpler:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; String msg = TextBox1.Text;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (DropDownList1.Text)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Alert&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;         ApplicationEnvironment.LogAlert(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Error&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;         ApplicationEnvironment.LogError(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Warning&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;         ApplicationEnvironment.LogWarning(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Information&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt;         ApplicationEnvironment.LogInformation(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Verbose&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  17:&lt;/span&gt;         ApplicationEnvironment.LogVerbose(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  18:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  19:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  20:&lt;/span&gt;         ApplicationEnvironment.LogError(&lt;span style="color:#006080;"&gt;&amp;quot;Unexpected kind&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  21:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  22:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Finally, there’s a button that creates a null reference exception so you can exercise the tools that you’ll use to debug code that runs in the cloud.&lt;/p&gt;

&lt;p&gt;You’ll note that all the code I’ve shown so far use this ApplicationEnvironment class. The ApplicationEnvironment class provides some basic capabilities that abstract away the core operating environment.&amp;#160; &lt;/p&gt;

&lt;p&gt;In its class constructor, it looks at the RoleManager and if the role manager is running, it determines that the operating environment is the cloud. Next, it looks to see if there is a web context. That would mean it’s running in a standard web environment. If neither of those facts are true, it assumes it is running on the desktop:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Button1_Click(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     String msg = TextBox1.Text;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;switch&lt;/span&gt; (DropDownList1.Text)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Alert&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;             ApplicationEnvironment.LogAlert(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Error&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;             ApplicationEnvironment.LogError(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Warning&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt;             ApplicationEnvironment.LogWarning(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Information&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;             ApplicationEnvironment.LogInformation(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  17:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  18:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;case&lt;/span&gt; &lt;span style="color:#006080;"&gt;&amp;quot;Verbose&amp;quot;&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  19:&lt;/span&gt;             ApplicationEnvironment.LogVerbose(msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  20:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;break&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  21:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;:&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  22:&lt;/span&gt;             ApplicationEnvironment.LogError(&lt;span style="color:#006080;"&gt;&amp;quot;Unexpected kind&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  23:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  24:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  25:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;You’ll notice from the code above that the constructor also constructs a logger object based on where its running.&amp;#160; A further dive into the code shows that the RoleManager class contains methods to write to a log in the Azure fabric. &lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&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;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; LogAlert(&lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; msg)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     RoleManager.WriteToLog(&lt;span style="color:#006080;"&gt;&amp;quot;Critical&amp;quot;&lt;/span&gt;, msg);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The other logger implementations should be familiar to any .NET developer.&lt;/p&gt;

&lt;p&gt;The last item you saw was reading a string from the configuration file.&amp;#160; That’s also different in the fabric, and the ApplicationEnvironment class abstracts that away from you.&amp;#160; To read configuration items while running in the fabric you use the RoleManager.GetConfigurationSetting method:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; RoleManager.GetConfigurationSetting(name);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Of course, to read something from a config file, you’ll have to put the data in a config file.&amp;#160; Azure changes that again.&amp;#160; You have to define your config settings in your service definition.csdef file:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;ConfigurationSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Setting&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;BannerText&amp;quot;&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Setting&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;LogAllRequests&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Setting&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;LogFailedRequests&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;ConfigurationSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;And, you assign values to them in the ServiceConfiguration.cscfg file:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;ConfigurationSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Setting&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;BannerText&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;Hello Fabric!&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Setting&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;LogAllRequests&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;false&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;   &lt;span style="color:#0000ff;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#800000;"&gt;Setting&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;name&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;LogFailedRequests&amp;quot;&lt;/span&gt; &lt;span style="color:#ff0000;"&gt;value&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color:#800000;"&gt;ConfigurationSettings&lt;/span&gt;&lt;span style="color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Of course, you saw that there are some other settings in those config files, and that’s how logging gets enabled, and that makes use of the other classes in the Common library used in this sample.&lt;/p&gt;

&lt;p&gt;The two boolean values affect an IHttpModule implementation that logs all requests, or just some of the requests.&amp;#160; When the module initializes, it reads the configuration setting and attaches a handler for all requests, or just error requests. The code demonstrates how to configure logging at runtime, because there is an overhead associated with the extra logging functionality.&lt;/p&gt;

&lt;p&gt;If you want to explore the fabric sample yourself, make sure you open the Device Fabric logger to see the logging capabilities. That’s where all the logging messages go in the end.&lt;/p&gt;

&lt;p&gt;In some ways, Azure development, at the code level, looks boring.&amp;#160; It’s too familiar. But then, that’s the point: Azure builds on the existing tools and libraries we already use. &lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=6508" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/3MUXYTBJwGs" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/C_2300_/default.aspx">C#</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Azure/default.aspx">Azure</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/02/21/looking-at-azure.aspx</feedburner:origLink></item><item><title>Book Review: Mike Cohn X 2</title><link>http://feedproxy.google.com/~r/billwagner/~3/3Sfu7p9_Rkc/book-review-mike-cohn-x-2.aspx</link><pubDate>Tue, 10 Feb 2009 03:08:22 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:6259</guid><dc:creator>wwagner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=6259</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/02/09/book-review-mike-cohn-x-2.aspx#comments</comments><description>&lt;p&gt;I’m covering two books by Mike Cohn in this post: &lt;a href="http://www.amazon.com/User-Stories-Applied-Development-Addison-Wesley/dp/0321205685/" target="_blank"&gt;User Stories Applied&lt;/a&gt;, and &lt;a href="http://www.amazon.com/Agile-Estimating-Planning-Robert-Martin/dp/0131479415/" target="_blank"&gt;Agile Estimating and Planning&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I’m reviewing them together because I read both of them at the same time, and some of the content is inter-twined in my own mind.&lt;/p&gt;  &lt;p&gt;Both books provide a wealth of practical advice on succeeding with an agile process. Throughout both books, the depth of Mike’s coaching experience comes through.&amp;#160; With every element of advice, Mike includes a discussion about why each recommendation is what it is. He also includes a lot of “you may be thinking of …” comments with reasons why straying from his advice may cost you and hurt your project.&lt;/p&gt;  &lt;p&gt;Throughout both books I found myself almost thinking Mike was inside my head, helping me improve. When an author does that, he’s clearly succeeding.&lt;/p&gt;  &lt;p&gt;The two books are aimed at different, but overlapping audiences.&amp;#160; Maybe because I’m in both audiences, I found both useful.&amp;#160; &lt;/p&gt;  &lt;p&gt;User Stories Applied goes into more depth about the process of creating user stories that will help drive your project to success. You’ll find advice that you should share with your customers. It will help them learn what makes a good user story, and how to express their needs and feature requests in the form of user stories. In addition, you and your team will gain a better understanding about creating stories that show value, are not too big, and aren’t too small to provide real value. You’ll learn how to break epics into measurable deliverables for your team. Those skills will help you succeed with agile. Software project success starts with getting good input from stakeholders and customers, regardless of which process you choose. Mike’s guidance in User Stories Applied will help your team, and your customers get this crucial part correct.&lt;/p&gt;  &lt;p&gt;Agile Estimating and Planning provides advice from a different angle. This book explains agile techniques from all angles: release planning, iteration planning, daily planning, and modifications when reality differs from estimates (you know, like it always does).&amp;#160; The best feature of this book is how Mike seems to anticipate counterarguments from those in any organization that would be opposed to adopting agile. He counters those arguments with clear logic and solid explanations about why following his advice will achieve better results. From different angles, you’ll find advice for developers, project leads, customers and customer proxies. Whichever role you find yourself in, read the entire book. Knowing how other team members should be approaching the process will help build a functioning team across processes.&lt;/p&gt;  &lt;p&gt;The key theme running through this book is that agile plans must be constantly revisited, because reality changes constantly. Agile planning is not something you do at the beginning of a project, it’s a series of ongoing activities throughout the project. That point is stresses repeatedly, and it’s worth it.&lt;/p&gt;  &lt;p&gt;If you are looking into agile, or you’ve tried an agile process and haven’t had the success you’d hoped for, you must read these books. It will help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=6259" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/3Sfu7p9_Rkc" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/books/default.aspx">books</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/BookReviews/default.aspx">BookReviews</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/02/09/book-review-mike-cohn-x-2.aspx</feedburner:origLink></item><item><title>Duck Typing with dynamic in C# 4.0</title><link>http://feedproxy.google.com/~r/billwagner/~3/LPWvfKziWYM/duck-typing-with-dynamic-in-c-4-0.aspx</link><pubDate>Fri, 06 Feb 2009 19:03:41 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:6216</guid><dc:creator>wwagner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=6216</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2009/02/06/duck-typing-with-dynamic-in-c-4-0.aspx#comments</comments><description>&lt;p&gt;One of the features I find very limiting in C# (and VB.NET) generics is the way constraints work.&lt;/p&gt;  &lt;p&gt;As you probably know, you can only specify generic constraints using interfaces, a single base class, struct or class, and the new() constraint.&amp;#160; That makes certain constructs very difficult.&amp;#160; For example, consider the following method:&lt;/p&gt;  &lt;div&gt;   &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;     &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&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;int&lt;/span&gt; Sum(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;&amp;gt; sequence)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; answer = &lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; d &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; sequence)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (answer.Equals(&lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;)))&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;             answer = d;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;             answer = d + answer;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; answer;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;pedantic search note: Don’t copy this code, use &lt;a href="http://msdn.microsoft.com/en-us/library/system.linq.enumerable.sum.aspx" target="_blank"&gt;Enumerable.Sum()&lt;/a&gt; instead.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Obviously, there’s nothing special about int in the above code. If I create a type that supports addition, I should be able to produce the Sum() for that collection. See the Vector struct and the similar extension method here:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&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;struct&lt;/span&gt; Vector : IEquatable&amp;lt;Vector&amp;gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&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;double&lt;/span&gt; X&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;         get;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         set;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;double&lt;/span&gt; Y&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;         get;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;         set;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; Vector &lt;span style="color:#0000ff;"&gt;operator&lt;/span&gt; +(Vector left, Vector right)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; Vector() { X = left.X + right.X, Y = left.Y + right.Y };&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  17:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  18:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  19:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Equals(Vector other)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  20:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  21:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; X == other.X &amp;amp;&amp;amp; Y == other.Y;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  22:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  23:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  24:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; Equals(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; obj)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  25:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  26:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!(obj &lt;span style="color:#0000ff;"&gt;is&lt;/span&gt; Vector))&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  27:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  28:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; Equals((Vector)obj);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  29:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  30:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;override&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; ToString()&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  31:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  32:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;X = {0}, Y = {1}&amp;quot;&lt;/span&gt;, X, Y);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  33:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  34:&lt;/span&gt; }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  35:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  36:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  37:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; Vector Sum(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;Vector&amp;gt; sequence)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  38:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  39:&lt;/span&gt;     Vector answer = &lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(Vector);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  40:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (Vector d &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; sequence)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  41:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  42:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (answer.Equals(&lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(Vector)))&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  43:&lt;/span&gt;             answer = d;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  44:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  45:&lt;/span&gt;             answer = d + answer;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  46:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  47:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; answer;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  48:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Well, that’s a lot of Ctrl-C/Ctrl-V reuse.&amp;#160; I hate that. Unfortunately, it’s difficult to create a nice generic method using this pattern.&amp;#160; The presence of a ‘+’ operator cannot be specified as a constraint. (A similar issue would occur with any other operator that could be overloaded.)&lt;/p&gt;

&lt;p&gt;C# 4.0 and dynamic should make this possible.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Editors note: The following sample does not compile with the PDC bits for the C# 4.0 compiler. From my reading, I believe it should be valid C# 4.0. I’ll update this entry if I’m mis-interpreting the 4.0 dynamic features.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Instead of using generics (e.g. Sum&amp;lt;T&amp;gt;), using a dynamic type should make this work with any type that does support the ‘+’ operator. I should be able to create the sum of a sequence of integers,&amp;#160; or a sequence of Vectors, or even a sequence of strings. The sequence of strings would concatenate the strings, because that’s how + is implemented for string.&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;
    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&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; dynamic Sum(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;dynamic&amp;gt; sequence)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     dynamic answer = &lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(dynamic);&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (dynamic d &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; sequence)&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (answer.Equals(&lt;span style="color:#0000ff;"&gt;default&lt;/span&gt;(dynamic)))&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;             answer = d;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;else&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;             answer = d + answer; &lt;span style="color:#008000;"&gt;// CTP:  Error CS0019&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:white;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; answer;&lt;/pre&gt;

    &lt;pre style="border-bottom-style:none;padding-bottom:0px;line-height:12pt;border-right-style:none;background-color:#f4f4f4;margin:0em;padding-left:0px;width:100%;padding-right:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-top-style:none;color:black;font-size:8pt;border-left-style:none;overflow:visible;padding-top:0px;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The current CTP does not provide dynamic binding for operators yet, but I believe it’s planned.&amp;#160; See &lt;a href="http://blogs.msdn.com/samng/archive/2008/12/11/dynamic-in-c-v-indexers-operators-and-more.aspx" target="_blank"&gt;here&lt;/a&gt;. And &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/vs2010ctpvbcs/thread/287db1b9-c135-40bc-a1c5-a8a51efbfc65" target="_blank"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The more I think about dynamic types in C# 4.0, the more interesting uses I se for them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=6216" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/LPWvfKziWYM" height="1" width="1"/&gt;</description><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2009/02/06/duck-typing-with-dynamic-in-c-4-0.aspx</feedburner:origLink></item></channel></rss>
