<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/rss2full.xsl" type="text/xsl" media="screen"?><?xml-stylesheet href="http://feeds.feedburner.com/~d/styles/itemcontent.css" type="text/css" media="screen"?><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 2007.1 (Build: 20917.1142)</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>Clarifying my comments on Previous Post</title><link>http://feeds.feedburner.com/~r/billwagner/~3/418006068/clarifying-my-comments-on-previous-post.aspx</link><pubDate>Sat, 11 Oct 2008 19:21:44 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4791</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4791</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/10/11/clarifying-my-comments-on-previous-post.aspx#comments</comments><description>&lt;p&gt;My last post generated valid criticisms from readers. Let’s clarify and correct that.&lt;/p&gt;  &lt;p&gt;&lt;a target="_blank" href="http://keithelder.net/blog/"&gt;Keith Elder&lt;/a&gt; commented: &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I got the impression reading your post that you &amp;quot;skimmed&amp;quot; my article and didn&amp;#39;t really get what it was I was getting at.     &lt;br /&gt;[…]&lt;/p&gt;    &lt;p&gt;The whole point of this is C# 3.0 can be written where it is unreadable (lambda as an example) but it can also make the code 200% more readable than the old way by combining several features, not just one. &lt;/p&gt;    &lt;p&gt;Although you say you disagree, I know we both agree because we both agree the LINQ example is the most readable.&amp;#160; Hugs all around :)&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Fair enough. The title of Keith’s post certainly led me to conclude that his point was that the new syntax made for less readable code. Not his intent, and clearly my fault.&amp;#160; My apologies for misinterpreting your intent.&lt;/p&gt;  &lt;p&gt;Sean comments:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;On the &amp;quot;don&amp;#39;t use it just to use it&amp;quot; idea, I admit that just throwing something in can be reckless, how can you know when to use it if you don&amp;#39;t blatantly experiment with it? &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;I would advocate ‘blatantly experimenting with it’. It’s a great way to learn where new features can help, and when you’ll run into weaknesses with that new feature.&lt;/p&gt;  &lt;p&gt;But…&lt;/p&gt;  &lt;p&gt;Before declaring a task done, take a moment and do your own review of the code.&amp;#160; In this sense, much like Keith explored multiple solutions in his blog post, look at alternatives, determine which is the most readable, and maintainable, and go with it. &lt;/p&gt;  &lt;p&gt;Another important technique to learn new techniques is reading code. Scott Hanselman’s “&lt;a target="_blank" href="http://www.hanselman.com/blog/CategoryView.aspx?category=Source+Code"&gt;Weekly Source Code&lt;/a&gt;” series is great example of how to do that.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4791" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/418006068" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/LINQ/default.aspx">LINQ</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><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/10/11/clarifying-my-comments-on-previous-post.aspx</feedburner:origLink></item><item><title>Creating Readable LINQ</title><link>http://feeds.feedburner.com/~r/billwagner/~3/416453005/creating-readable-linq.aspx</link><pubDate>Fri, 10 Oct 2008 04:40:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4765</guid><dc:creator>wwagner</dc:creator><slash:comments>3</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4765</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/10/10/creating-readable-linq.aspx#comments</comments><description>&lt;p&gt;Keith Elder wrote a post a post asserting (or at least proposing) that a more imperative syntax for a problem is more readable than a LINQ based C# 3.0 version. (See &lt;a href="http://keithelder.net/blog/archive/2008/10/08/Balancing-Readability-and-New-Syntax-Sugar-in-C-3.0.aspx" target="_blank"&gt;here&lt;/a&gt; for his post).&amp;nbsp; Well, that got my hackles up.&amp;nbsp; Some days, my hackles get up before I do, but I digress.&lt;/p&gt;  &lt;p&gt;His example code as examining IP addresses for a machine. His poor example was this:&lt;/p&gt;  &lt;div style="border:1px solid gray;margin:20px 0px 10px;padding:4px;overflow:auto;line-height:12pt;width:97.5%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;max-height:200px;font-size:8pt;cursor:text;"&gt;   &lt;div style="border-style:none;padding:0px;overflow:visible;line-height:12pt;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;     &lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;line-height:12pt;background-color:white;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;&lt;span&gt;   1:&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; ipAddy = Dns.GetHostAddresses(Dns.GetHostName()).Single(i =&amp;gt; ValidateIP4Address(i.ToString())).ToString();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;(ValidateIP4Address is shown in Keith’s example, and is not repeated here).&lt;/p&gt;

&lt;p&gt;I’ll agree with Keith on one point: that’s ugly code. Formatting is only part of it. It’s also not leveraging one of the features that make LINQ readable: query expressions. It uses two different conversions from each IP address to a string.&amp;nbsp; Much of the core logic is hidden.&lt;/p&gt;

&lt;p&gt;Let’s try this instead:&lt;/p&gt;

&lt;div&gt;
  &lt;div style="border-style:none;padding:0px;overflow:visible;line-height:12pt;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;
    &lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;line-height:12pt;background-color:white;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;&lt;span&gt;   1:&lt;/span&gt; var ipAddy = (from address &lt;span&gt;in&lt;/span&gt; Dns.GetHostAddresses(Dns.GetHostName())&lt;/pre&gt;

    &lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;line-height:12pt;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;&lt;span&gt;   2:&lt;/span&gt;               let addressLabel = address.ToString()&lt;/pre&gt;

    &lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;line-height:12pt;background-color:white;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;&lt;span&gt;   3:&lt;/span&gt;               &lt;span&gt;where&lt;/span&gt; ValidateIP4Address(addressLabel)&lt;/pre&gt;

    &lt;pre style="border-style:none;margin:0em;padding:0px;overflow:visible;line-height:12pt;width:100%;font-family:consolas,&amp;#39;Courier New&amp;#39;,courier,monospace;color:black;font-size:8pt;"&gt;&lt;span&gt;   4:&lt;/span&gt;               select addressLabel).First();&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The first line of the query defines the source: Host addresses.&lt;/p&gt;

&lt;p&gt;The second line defines a local variable to cache the string representation of the address.&lt;/p&gt;

&lt;p&gt;The third line defines the filter condition: A valid IP4 address.&lt;/p&gt;

&lt;p&gt;And the fourth line defines the result: A single string, the first in the sequence&lt;/p&gt;

&lt;p&gt;I’ll agree that if you haven’t looked at LINQ code very much, this can still appear hard to read. But that’s a short-term argument: If you’re reading my blog, you&amp;#39;re a developer, and you should be learning new features in whatever language you are using. &lt;/p&gt;

&lt;p&gt;Some of Keith’s concerns are very valid: pulling out the latest new features just to use them and experiment with whatever looks interesting will create bad code. But there is a lot to be gained by using the new features carefully, and adding them in the appropriate manner, and following the best idioms for the newer features.&lt;/p&gt;

&lt;p&gt;There’s plenty of resources to help you. Use them, and discuss readability with your peers. It’s the only way you’ll know what other developers will understand.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4765" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/416453005" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/LINQ/default.aspx">LINQ</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/local+interest/default.aspx">local interest</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/2008/10/10/creating-readable-linq.aspx</feedburner:origLink></item><item><title>Paul Kimmel interviews me about C#, LINQ, and writing books</title><link>http://feeds.feedburner.com/~r/billwagner/~3/412745336/paul-kimmel-interviews-me-about-c-linq-and-writing-books.aspx</link><pubDate>Mon, 06 Oct 2008 12:06:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4728</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4728</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/10/06/paul-kimmel-interviews-me-about-c-linq-and-writing-books.aspx#comments</comments><description>&lt;p&gt;Paul Kimmel spent some time over the summer chatting with me about &lt;a href="http://www.amazon.com/More-Effective-Specific-Software-Development/dp/0321485890/ref=pd_ts_b_26?ie=UTF8&amp;amp;s=books"&gt;More Effective C#&lt;/a&gt;, LINQ, upcoming C# features, and the process of writing books.&amp;nbsp; It&amp;#39;s live here: &lt;a href="http://www.informit.com/articles/article.aspx?p=1237069"&gt;http://www.informit.com/articles/article.aspx?p=1237069&lt;/a&gt;&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4728" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/412745336" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Me/default.aspx">Me</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><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/10/06/paul-kimmel-interviews-me-about-c-linq-and-writing-books.aspx</feedburner:origLink></item><item><title>Euler Problem 11, or it’s about time I wrote some code</title><link>http://feeds.feedburner.com/~r/billwagner/~3/409555859/euler-problem-11-or-it-s-about-time-i-wrote-some-code.aspx</link><pubDate>Thu, 02 Oct 2008 19:17:52 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4697</guid><dc:creator>wwagner</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4697</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/10/02/euler-problem-11-or-it-s-about-time-i-wrote-some-code.aspx#comments</comments><description>&lt;p&gt;I just needed to write some code last night, so I figured I’d pull out the Euler problems and solve another.&lt;/p&gt;  &lt;p&gt;Problem 11 asks you to find the largest product of any sequence of 4 numbers in a 20 x 20 grid. The sequence can be horizontal, vertical, or diagonal. As with the other problems, my goal is to display how C# 3.0 syntax enhancements can be best exploited for this problem.&lt;/p&gt;  &lt;p&gt;I wrote two very similar solutions to problem 11 so that you can see how LINQ mixes imperative and functional styles, and how lazy evaluation means that the different expressions of the solution actually have similar characteristics at runtime.&lt;/p&gt;  &lt;p&gt;The algorithm must search through the grid four times finding all the candidate sequences: horizontal, vertical, down-right, and down-left. There are four LINQ queries that find possible answer sequences. To find the single answer, you must find the max value across all four queries. &lt;/p&gt;  &lt;p&gt;A more pure functional solution creates a single query by concatenating the four queries together. Then, after concatenating all four queries, it calls order by to find the max:&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 best = (from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17) &lt;span style="color:#008000;"&gt;// horizontal&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;             from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 20)&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;             let first = data[x, 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;   4:&lt;/span&gt;             let second = data[x + 1, 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;   5:&lt;/span&gt;             let third = data[x + 2, 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;   6:&lt;/span&gt;             let fourth = data[x + 3, 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;   7:&lt;/span&gt;             let answer = first * second *&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;                     third * fourth&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;             select &lt;span style="color:#0000ff;"&gt;new&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;                 X = 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;  12:&lt;/span&gt;                 Y = 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;  13:&lt;/span&gt;                 Direction = &lt;span style="color:#006080;"&gt;&amp;quot;Right&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;                 Values =&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;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;                     first, second,&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;                     third, fourth),&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;                 Answer = answer&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;             }).Concat(from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 20) &lt;span style="color:#008000;"&gt;// Vertical&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;                       from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)&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;                       let first = data[x, 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;                       let second = data[x, y + 1]&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;                       let third = data[x, y + 2]&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;                       let fourth = data[x, y + 3]&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;                       let answer = first * second *&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;                               third * fourth&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;                       select &lt;span style="color:#0000ff;"&gt;new&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;/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;                           X = 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;  30:&lt;/span&gt;                           Y = 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;  31:&lt;/span&gt;                           Direction = &lt;span style="color:#006080;"&gt;&amp;quot;Down&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;  32:&lt;/span&gt;                           Values =&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;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;  34:&lt;/span&gt;                               first, second,&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;                               third, fourth),&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;                           Answer = answer&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;                       }).Concat(from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)  &lt;span style="color:#008000;"&gt;// Down to the right&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;  38:&lt;/span&gt;                                 from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)&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;                                 let first = data[x, 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;  40:&lt;/span&gt;                                 let second = data[x + 1, y + 1]&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;                                 let third = data[x + 2, y + 2]&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;                                 let fourth = data[x + 3, y + 3]&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;                                 let answer = first * second *&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;                                         third * fourth&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;                                 select &lt;span style="color:#0000ff;"&gt;new&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;  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;                                     X = 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;  48:&lt;/span&gt;                                     Y = 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;  49:&lt;/span&gt;                                     Direction = &lt;span style="color:#006080;"&gt;&amp;quot;DownRight&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;  50:&lt;/span&gt;                                     Values =&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;  51:&lt;/span&gt;                                      &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;  52:&lt;/span&gt;                                         first, second,&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;  53:&lt;/span&gt;                                         third, fourth),&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;  54:&lt;/span&gt;                                     Answer = answer&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;  55:&lt;/span&gt;                                 }).Concat(from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(3, 17)&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;  56:&lt;/span&gt;                                           from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)&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;  57:&lt;/span&gt;                                           let first = data[x, 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;  58:&lt;/span&gt;                                           let second = data[x - 1, y + 1]&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;  59:&lt;/span&gt;                                           let third = data[x - 2, y + 2]&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;  60:&lt;/span&gt;                                           let fourth = data[x - 3, y + 3]&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;  61:&lt;/span&gt;                                           let answer = first * second *&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;  62:&lt;/span&gt;                                                   third * fourth&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;  63:&lt;/span&gt;                                           select &lt;span style="color:#0000ff;"&gt;new&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;  64:&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;  65:&lt;/span&gt;                                               X = 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;  66:&lt;/span&gt;                                               Y = 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;  67:&lt;/span&gt;                                               Direction = &lt;span style="color:#006080;"&gt;&amp;quot;DownLeft&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;  68:&lt;/span&gt;                                               Values =&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;  69:&lt;/span&gt;                                                &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;  70:&lt;/span&gt;                                                   first, second,&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;  71:&lt;/span&gt;                                                   third, fourth),&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;  72:&lt;/span&gt;                                               Answer = answer&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;  73:&lt;/span&gt;                                           }).OrderByDescending((record) =&amp;gt; record.Answer).First();&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;  74:&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;  75:&lt;/span&gt; Console.WriteLine(best);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Of course, many folks are turned off by seeing 70+ lines of code with a single semi-colon. So here’s a different refactoring of the same code. In the following version, I construct four different queries. &lt;em&gt;It’s important to understand that constructing a query in LINQ is not the same as executing it.&lt;/em&gt; After constructing four distinct queries, I concatenate them, and find the max.&amp;#160; The C# compiler can correctly determine that all four queries project a sequence of the same anonymous type, so all four query results can be concatenated.&amp;#160; (If you really want, you can look in Reflector and find that the compiler generates only one anonymous type for the query result objects.)&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;var horizontal = from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17) &lt;span style="color:#008000;"&gt;// horizontal&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;                 from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 20)&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;                 let first = data[x, 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;                 let second = data[x + 1, 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;                 let third = data[x + 2, 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;                 let fourth = data[x + 3, 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;                 let answer = first * second *&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;                         third * fourth&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;                 select &lt;span style="color:#0000ff;"&gt;new&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;/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;                     X = 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;                     Y = 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;                     Direction = &lt;span style="color:#006080;"&gt;&amp;quot;Right&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;                     Values =&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:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;                         first, second,&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;                         third, fourth),&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;                     Answer = answer&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;/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;var vertical = from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 20) &lt;span style="color:#008000;"&gt;// Vertical&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;               from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)&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;               let first = data[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;               let second = data[x, y + 1]&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;               let third = data[x, y + 2]&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;               let fourth = data[x, y + 3]&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;               let answer = first * second *&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;                       third * fourth&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;               select &lt;span style="color:#0000ff;"&gt;new&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;/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;                   X = x,&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;                   Y = 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;                   Direction = &lt;span style="color:#006080;"&gt;&amp;quot;Down&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;                   Values =&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:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;                       first, second,&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;                       third, fourth),&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;                   Answer = 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;/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;var downRight = from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)  &lt;span style="color:#008000;"&gt;// Down to the right&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;                from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)&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;                let first = data[x, 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;                let second = data[x + 1, y + 1]&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;                let third = data[x + 2, y + 2]&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;                let fourth = data[x + 3, y + 3]&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;                let answer = first * second *&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;                        third * fourth&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;                select &lt;span style="color:#0000ff;"&gt;new&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;/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;                    X = 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;                    Y = 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;                    Direction = &lt;span style="color:#006080;"&gt;&amp;quot;DownRight&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;                    Values =&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:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;                        first, second,&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;                        third, fourth),&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;                    Answer = answer&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;/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;var downLeft = from x &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(3, 17)&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;               from y &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; Enumerable.Range(0, 17)&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;               let first = data[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;               let second = data[x - 1, y + 1]&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;               let third = data[x - 2, y + 2]&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;               let fourth = data[x - 3, y + 3]&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;               let answer = first * second *&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;                       third * fourth&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;               select &lt;span style="color:#0000ff;"&gt;new&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;/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;                   X = x,&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;                   Y = 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;                   Direction = &lt;span style="color:#006080;"&gt;&amp;quot;DownLeft&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;                   Values =&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:#0000ff;"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#006080;"&gt;&amp;quot;{0}, {1}, {2}, {3}&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;                       first, second,&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;                       third, fourth),&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;                   Answer = 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;/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;&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;var best = horizontal.&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;    Concat(vertical).&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;    Concat(downRight).&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;    Concat(downLeft).&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;    OrderByDescending((record) =&amp;gt; record.Answer).First();&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;Console.WriteLine(best);&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;There’s one other interesting bit of syntax that should be noted here.&amp;#160; I’ve used ‘let’ in all the queries to avoid recomputing the same result, and to ensure that I’ve avoided any copy/paste errors as I put together the answer.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4697" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/409555859" height="1" width="1"/&gt;</description><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/10/02/euler-problem-11-or-it-s-about-time-i-wrote-some-code.aspx</feedburner:origLink></item><item><title>DNR TV on C# 3.0 is live</title><link>http://feeds.feedburner.com/~r/billwagner/~3/406416676/dnr-tv-on-c-3-0-is-live.aspx</link><pubDate>Mon, 29 Sep 2008 16:23:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4659</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4659</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/09/29/dnr-tv-on-c-3-0-is-live.aspx#comments</comments><description>&lt;p&gt;Last week, I recorded a DNR TV with Carl Franklin discussing C# 3.0 extension methods, local type inference and some of the best practices that revolve around those parts of the languages.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;It&amp;#39;s up and live now.&amp;nbsp; Check it out &lt;a href="http://www.dnrtv.com/default.aspx?showID=125"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4659" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/406416676" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/LINQ/default.aspx">LINQ</category><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Me/default.aspx">Me</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><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/09/29/dnr-tv-on-c-3-0-is-live.aspx</feedburner:origLink></item><item><title>Cloud Computing: A new place for my stuff?</title><link>http://feeds.feedburner.com/~r/billwagner/~3/402395067/cloud-computing-a-new-place-for-my-stuff.aspx</link><pubDate>Thu, 25 Sep 2008 02:47:52 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4628</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4628</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/09/24/cloud-computing-a-new-place-for-my-stuff.aspx#comments</comments><description>&lt;p&gt;One of the big areas of coverage for this year&amp;#39;s PDC (&lt;a href="http://www.microsoftpdc.com"&gt;http://www.microsoftpdc.com&lt;/a&gt;) is Microsoft&amp;#39;s cloud computing platform. You&amp;#39;ve already seen some of the concept with LiveMesh (&lt;a href="http://www.LiveMesh.net"&gt;www.LiveMesh.net&lt;/a&gt;). The long list of talks on cloud computing, working with Live Mesh, and similar topics make me think there is clearly a lot more under the covers here.&amp;nbsp; &lt;/p&gt; &lt;p&gt;Personally, I&amp;#39;m hoping for a clear programming model that lets me use the clould for storing all my data. I&amp;#39;ve said before about relational databases:&amp;nbsp; It&amp;#39;s just a place for my stuff.&amp;nbsp; I&amp;#39;m more than happy to let others that are more skilled in T-SQL and optimizing that layer handle the particulars. It&amp;#39;s a place for my stuff.&lt;/p&gt; &lt;p&gt;I&amp;#39;m hopeful that the cloud computing model is similar:&amp;nbsp; I want to view the cloud as a place for my stuff. It should be that simple.&lt;/p&gt; &lt;p&gt;And, like the old George Carlin monologue, I want to take some of my stuff with me. No matter where I go, I want to get at my stuff. &lt;/p&gt; &lt;p&gt;That&amp;#39;s why I&amp;#39;m going to PDC: I want to know as much as I can about this model, so I can get my apps and my customers ready to leverage it as soon as it&amp;#39;s ready for use.&lt;/p&gt; &lt;p&gt;The monster hard drive with the goods must have some cloud bits on it.&lt;/p&gt; &lt;p&gt;Note on the video:&amp;nbsp; Might not be safe for work (It&amp;#39;s George Carlin, and it uses a few words some may not like). &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;a target="_blank" href="http://www.youtube.com/watch?v=MvgN5gCuLac"&gt;George Carlin&amp;#39;s &amp;quot;A Place for My Stuff&amp;quot;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4628" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/402395067" height="1" width="1"/&gt;</description><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/.NET+General/default.aspx">.NET General</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/09/24/cloud-computing-a-new-place-for-my-stuff.aspx</feedburner:origLink></item><item><title>I'm a PC</title><link>http://feeds.feedburner.com/~r/billwagner/~3/400161146/i-m-a-pc.aspx</link><pubDate>Mon, 22 Sep 2008 21:30:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4606</guid><dc:creator>wwagner</dc:creator><slash:comments>4</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4606</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/09/22/i-m-a-pc.aspx#comments</comments><description>&lt;p&gt;The I&amp;#39;m a PC ads are great.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;I like the tone, the content, and the message: PCs create are world without walls, where communication is world wide, different industries, hobbies, goals, and types of hardware are supported.&amp;nbsp; It&amp;#39;s great, and shows the incredible breadth and diversity of the PC and Windows community. Breadth of interests, breadth in geography, breadth of thought, breadth of problems, breadth of solutions.&lt;/p&gt;
&lt;p&gt;You can view the videos &lt;a target="_blank" href="http://www.microsoft.com/presspass/windows/videoGallery.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re different, not like that monolithic Mac world, you can upload your photo or video here: &lt;a title="http://imapc.lifewithoutwalls.com" href="http://imapc.lifewithoutwalls.com/"&gt;http://imapc.lifewithoutwalls.com&lt;/a&gt;&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4606" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/400161146" 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/products/default.aspx">products</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/09/22/i-m-a-pc.aspx</feedburner:origLink></item><item><title>Channel 9 interview with the VS.NET IDE team</title><link>http://feeds.feedburner.com/~r/billwagner/~3/387842856/channel-9-interview-with-the-vs-net-ide-team.aspx</link><pubDate>Tue, 09 Sep 2008 17:01:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4547</guid><dc:creator>wwagner</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4547</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/09/09/channel-9-interview-with-the-vs-net-ide-team.aspx#comments</comments><description>&lt;p&gt;Is located &lt;a class="" href="http://channel9.msdn.com/posts/funkyonex/Meet-the-Visual-Studio-Managed-Languages-Development-Experience-Team/"&gt;here&lt;/a&gt;. It&amp;#39;s well worth 30 minutes of your time.&lt;/p&gt;
&lt;p&gt;Observation: Dustin is fitting in quite well with a great team.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4547" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/387842856" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Links/default.aspx">Links</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/2008/09/09/channel-9-interview-with-the-vs-net-ide-team.aspx</feedburner:origLink></item><item><title>My 24 hours with Chrome</title><link>http://feeds.feedburner.com/~r/billwagner/~3/383705275/my-24-hours-with-chrome.aspx</link><pubDate>Thu, 04 Sep 2008 23:53:18 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4506</guid><dc:creator>wwagner</dc:creator><slash:comments>6</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4506</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/09/04/my-24-hours-with-chrome.aspx#comments</comments><description>&lt;p&gt;Or the luster is already gone.&lt;/p&gt; &lt;p&gt;I used Chrome for some of my web browsing for about one day. It works alright, but it&amp;#39;s clearly an early release.&amp;nbsp;&amp;nbsp; Technically, Chrome can and will compete with Firefox 3 and IE 8. (I&amp;#39;m running a beta of IE 8 as my regular browser at the moment.)&lt;/p&gt; &lt;p&gt;The reason I removed Chrome is entirely based on the EULA (even though it is changing). It may be a bit of paranoia, but it is my opinion. &lt;/p&gt; &lt;p&gt;I freely admit to having concerns about Google and privacy, more so than any other software company. That&amp;#39;s entirely because of their business model.&amp;nbsp; Other software companies want an ongoing relationship with their customers. That shortens the sales cycle. But Google is different. Google doesn&amp;#39;t sell me anything. It sells access to me (and others like me) to advertisers. The more demographic information they have about me (and others like me) the better they are able to satisfy their customers: the advertisers. It&amp;#39;s in their business interest to collect as much data about their users as possible. Note that I make the distinction between users and customers: Advertisers are Google&amp;#39;s customers. You and I (and others like us) are users. Google must satisfy its customers: the advertisers.&lt;/p&gt; &lt;p&gt;Despite such platitudes as &amp;quot;don&amp;#39;t be evil&amp;quot;, Google must keep advertisers happy if they are to succeed. Keeping users happy is important only in so much as a lack of any users will affect how well Google can sell add space.&lt;/p&gt; &lt;p&gt;That analysis makes me somewhat concerned anytime Google wants to know something about me (and others like me). They have a profit motive to know enough about me to target ads at me (and others like me). I prefer Google know less about me. &lt;/p&gt; &lt;p&gt;If you&amp;#39;ve read anything about Chrome&amp;#39;s EULA, you know that I&amp;#39;m concerned about Chrome, and Google&amp;#39;s ability to track my every move online. They have a profit motive to know as much as possible. The biggest risk of this, (to me) is the way their Omnibar can track everything I type. Depending on Google&amp;#39;s use of that data, it&amp;#39;s almost spyware.&lt;/p&gt; &lt;p&gt;The EULA has another clause (which Google is updating, but I haven&amp;#39;t seen the updates) that gives Google a non-exclusive license to all content created with Chrome. That&amp;#39;s also clearly part of Google&amp;#39;s profit motive: the more content they can deliver to end users, the more advertisers are willing to pay Google to deliver ads. The simplest answer is that I don&amp;#39;t intend to give Google (or anyone else) that kind of broad license.&amp;nbsp; &lt;/p&gt; &lt;p&gt;I&amp;#39;m sure Google will continue to address these issues over time, and I&amp;#39;m also sure I&amp;#39;ll give Chrome another look as they do so.&amp;nbsp; In the meantime, I will be watching how much marketshare Chrome achieves. At the moment, I don&amp;#39;t expect it will grow quickly: too many people have similar concerns about the EULA, and the privacy concerns.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4506" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/383705275" 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/products/default.aspx">products</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/09/04/my-24-hours-with-chrome.aspx</feedburner:origLink></item><item><title>Euler Problem 10</title><link>http://feeds.feedburner.com/~r/billwagner/~3/379779188/euler-problem-10.aspx</link><pubDate>Sun, 31 Aug 2008 17:05:00 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4443</guid><dc:creator>wwagner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4443</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/08/31/euler-problem-10.aspx#comments</comments><description>&lt;p&gt;Patrick &lt;a href="http://srtsolutions.com/blogs/patricksteele/archive/2008/08/27/euler-10.aspx" target="_blank"&gt;posted&lt;/a&gt; his solution earlier this week. I figure it was time to add mine.&lt;/p&gt; &lt;p&gt;Also, &lt;a href="http://geeks.ms/blogs/ohernandez/default.aspx" target="_blank"&gt;Octavio Hernandez&lt;/a&gt; pointed out in the comments to problem 8 that he had discussed similar code constructs in his &lt;a href="http://geeks.ms/blogs/ohernandez/archive/2007/04/27/should-we-learn-a-new-way-of-writing-loops.aspx" target="_blank"&gt;blog&lt;/a&gt; a while back.&lt;/p&gt; &lt;p&gt;Problem 10 asks for the sum of all primes less than 2 million. It&amp;#39;s also one line of LINQ code:&lt;/p&gt; &lt;div&gt; &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; var number = Common.Primes.GeneraePrimes().TakeWhile((n) =&amp;gt; n &amp;lt; 2000000).Sum();&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; Console.WriteLine(number);&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;As Patrick pointed out, this will cause an overflow unless you make some changes to the GeneratePrimes() method so that it returns a sequence of longs instead of a sequence of ints.&lt;/p&gt;
&lt;p&gt;I also wasn&amp;#39;t thrilled with the fact that it was taking a few minutes to finish instead of seconds.&amp;nbsp; That needed some fixing.&lt;/p&gt;
&lt;p&gt;George Byrkit pointed out that the math can be optimized by recognizing that the highest factor you need to check for any N is Sqrt(N). &lt;/p&gt;
&lt;p&gt;Sadly, the current .NET Framework does not contain methods that do the check efficiently. George suggested using List&amp;lt;T&amp;gt;FindAll() to find only those numbers smaller than the target. That method is a member of List and creates a new List object. Yuck. Also, it doesn&amp;#39;t perform lazy evaluation, and it checks the entire list.&lt;/p&gt;
&lt;p&gt;But now that the numbers have gotten much larger, it&amp;#39;s worth the work to create my own version of those methods that speed this up.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the new version of IsPrime:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; IEnumerable&amp;lt;&lt;span style="color:#0000ff;"&gt;long&lt;/span&gt;&amp;gt; GeneratePrimes()&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     var range = Enumerable.Range(2, &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt;.MaxValue-1);&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     var answers = from number &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; range&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;                   &lt;span style="color:#0000ff;"&gt;where&lt;/span&gt; number.IsPrime()&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;                   select (&lt;span style="color:#0000ff;"&gt;long&lt;/span&gt;)number;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; answers;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The only change here is to cast the prime number to a long before returning.&lt;/p&gt;
&lt;p&gt;IsPrime gets a slightly larger makeover:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; IsPrime(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;int&lt;/span&gt; number)&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; isPrime = knownPrimes.TakeWhile(n =&amp;gt; n*n &amp;lt;= number).&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;         TrueForAll(n =&amp;gt; number % n != 0);                   &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (isPrime)&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         knownPrimes.Add(number);&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; isPrime;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;The astute reader will immediately notice that I&amp;#39;m calling TrueForAll using an IEnumerable&amp;lt;int&amp;gt; instead of a List&amp;lt;int&amp;gt;. That&amp;#39;s not supposed to compile. And in fact, it doesn&amp;#39;t, until I write my own version of TrueForAll:&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;bool&lt;/span&gt; TrueForAll&amp;lt;T&amp;gt;(&lt;span style="color:#0000ff;"&gt;this&lt;/span&gt; IEnumerable&amp;lt;T&amp;gt; sequence, Predicate&amp;lt;T&amp;gt; test)&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;foreach&lt;/span&gt; (T item &lt;span style="color:#0000ff;"&gt;in&lt;/span&gt; sequence)&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;         &lt;span style="color:#0000ff;"&gt;if&lt;/span&gt; (!test(item))&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;             &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;false&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt; }&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;Note that this is typed for IEnumerable&amp;lt;T&amp;gt;, so the compiler will use this version on sequences that are not List&amp;lt;T&amp;gt;, but will still use the base framework version for all List&amp;lt;T&amp;gt; types.&lt;/p&gt;
&lt;p&gt;And, now it produces the correct answers in under a minute.&lt;/p&gt;&lt;img src="http://srtsolutions.com/aggbug.aspx?PostID=4443" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/billwagner/~4/379779188" height="1" width="1"/&gt;</description><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/LINQ/default.aspx">LINQ</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/.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><category domain="http://srtsolutions.com/blogs/billwagner/archive/tags/Euler/default.aspx">Euler</category><feedburner:origLink>http://srtsolutions.com/blogs/billwagner/archive/2008/08/31/euler-problem-10.aspx</feedburner:origLink></item><item><title>Code from Lightning Talk: Compiler Tricks</title><link>http://feeds.feedburner.com/~r/billwagner/~3/379199393/code-from-lightning-talk-compiler-tricks.aspx</link><pubDate>Sat, 30 Aug 2008 21:53:58 GMT</pubDate><guid isPermaLink="false">727bb5a1-3d8b-4cbc-a411-ac1a71136f7d:4437</guid><dc:creator>wwagner</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://srtsolutions.com/blogs/billwagner/rsscomments.aspx?PostID=4437</wfw:commentRss><comments>http://srtsolutions.com/blogs/billwagner/archive/2008/08/30/code-from-lightning-talk-compiler-tricks.aspx#comments</comments><description>&lt;p&gt;My last Lightning Talk should how you can mix constructor calls and object initializers. It&amp;#39;s a useful technique that can keep you from writing too much code you don&amp;#39;t need.&lt;/p&gt; &lt;p&gt;To see what I mean, start with this simple person class:&lt;/p&gt; &lt;div&gt; &lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   1:&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt; Person&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   3:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; FirstName&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   5:&lt;/span&gt;         get;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   6:&lt;/span&gt;         set;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   7:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   8:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;   9:&lt;/span&gt;     &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;string&lt;/span&gt; LastName&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  11:&lt;/span&gt;         get;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  12:&lt;/span&gt;         set;&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  13:&lt;/span&gt;     }&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  14:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  15:&lt;/span&gt; }&lt;/pre&gt;&lt;pre style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;margin:0em;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-right-style:none;border-left-style:none;background-color:#f4f4f4;border-bottom-style:none;"&gt;&lt;span style="color:#606060;"&gt;  16:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;You can initialize a person using the new object initialier syntax:&lt;/p&gt;
&lt;div&gt;
&lt;div style="padding-right:0px;padding-left:0px;font-size:8pt;padding-bottom:0px;overflow:visible;width:100%;color:black;border-top-style:none;line-height:12pt;padding-top:0px;font-family:consolas, &amp;#39;Courier New&amp;#39;, courier, monospace;border-r