And here we have yet another post inspired by a question on StackOverflow : how do you compute the Cartesian product of arbitrarily many sequences using LINQ? (*)
UPDATE: Ian Griffiths has an interesting series of articles that approaches this question...

I've just returned from a week in Oslo, Norway, where I spoke at NDC 2010, immediately following a week in New Orleans, where I spoke at TechEd. I'm about nine hours jetlagged and glad to be home, though I had a lovely time. Many thanks in particular...

Another interesting question from StackOverflow. That thing is a gold mine for blog topics. Consider the following:
class B { public int X() { return 123; } } class D : B { new protected int X() { return 456; } } class E : D { public int Y() { return...

Today, another entertaining question from StackOverflow . Presented again as a dialogue, as is my wont.
The specification says " even though constants are considered static members, a constant-declaration neither requires nor allows a static modifier...

Just a quick note that Mads, Luke and I are going to be on Channel 9 Live from TechEd this afternoon talking about C#, F# and whatever else strikes our fancy. It's live video; anything can happen. Tune in to www.msteched.com ; we're scheduled to be on...

Good heavens, I just realized I completely forgot to post a link to this interview . I'm a year late, but better late than never.
A year ago Ken stopped by my office and we had a very freewheeling, entertaining and rather random conversation about...

No computer stuff today.
Martin Gardner - writer, skeptic, recreational mathematician - died recently. As a teenager I would scour the back room of Casablanca Books looking for back issues of Scientific American for interesting Mathematical Recreation...

Hey everybody, just a quick FYI, I will be attending TechEd New Orleans this year. I'll be hanging out at Mads' sessions, manning the booth and attending as many parties as I can fit in, so if you want to stop by and say hi, please do.
I'll then be...

Another interesting question from StackOverflow . Consider the following unfortunate situation:
object result; bool isDecimal = GetAmount(out result); decimal amount = (decimal)(isDecimal ? result : 0);
The developer who wrote this code was quite...

Hey everyone, those of you who read this blog on the main MSDN page rather than via your own RSS reader have probably noticed that the new default themes went live yesterday.
I am aware that the new theme does not make particularly efficient use of...

[This is the final part of a series on generating every string in a language. The previous part is here .] We seem to have a bit of a performance problem here. We could slap a profiler on it, and normally I’d recommend just that. But in this case, let...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] OK, first things first. Let’s assume that we have a string that contains a grammar that has already been rewritten into our “nice...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] Things seem to be going so well. We have a sketch of a recursive solution for enumerating all strings of a particular grammar and...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] The problem we ran into with our grammar-enumeration technique is that the recursion does not clearly reduce the problem to a smaller...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] Last time: Clearly we have reduced a problem of size k to multiple problems of size less than k-1, and so this is amenable to a recursive...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] Remember, the point of this exercise was to come up with a device to help me test parts of my compiler. To test binary trees as we...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] Suppose we want to write a grammar for a simplified C# class declaration. Let’s say that there are one-character identifiers, a class...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] Suppose we want to come up with a CFG for numbers with additions. Consider this very simple grammar with only one nonterminal. We...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] We can now enumerate every binary tree and every arbitrary tree of a given size, and therefore we can enumerate all of them, period...

[This is part of a series on generating every string in a language. The previous part is here . The next part is here .] Last time we talked about how the number of binary trees with n nodes is C(n), where C(n) is the nth Catalan number. I asked if there...

[This is the first part of a series on generating every string in a language. The next part is here .] The other day I wrote a little algorithm that did some operation on binary trees. I wanted to test it. I whipped up a few little test cases and it seemed...

My copy of Essential C# 4.0 just arrived, and it looks great. I was one of the technical reviewers of this book. Some books are a pain to edit, but the Essential C# series is one of my favourites. It totally lives up to its name; it really does give you...

Yet another amusing question from StackOverflow : is there a difference between “return something;” and “return (something);” in C#?
In practice , there is no difference.
In theory there could be a difference. There are three interesting points...

The DateTime struct represents dates as a 64 bit number that measures the number of “ticks” since a particular start date. Ten million ticks equals one second. That’s a quite high degree of precision . You can represent dates and times to sub-microsecond...

I was amused to read this post about an arithmetic bug which accidentally turned into an AI feature (found via Raymond’s recent link clearance .) It reminded me of a story that my friend Lars told me about working on a certain well-known first-person...