I have a Fit, but a lack of Focus.

Here’s a statement I read the other day about making comparisons between objects of reference type in C#: Object.ReferenceEquals(x,y) returns true if and only if x and y refer to the same object. True or false? My wife Leah recently acquired a Honda Fit, thanks to the imminant failure of the automatic transmission solenoids in…


Some new videos

Somehow it has happened again; people just keep on recording videos of me and putting them on the internet. In these videos you find out what I look like when lit from above and behind. Kinda spooky. We should have made the room entirely dark and held a flashlight underneath my face. That would be,…


Begging the question

In my last post I described the syllogism “Photogenic people look good in photograps; Michelle Pfeiffer is photogenic; therefore, Michelle Pfeiffer looks good in photographs” as “begging the question”. A few people commented on that, so I thought I’d address this point of English usage. In modern usage, “begging the question” has come to mean…


What is this thing you call "thread safe"?

Caveat: I am not an expert on multi-threading programming. In fact, I wouldn’t even say that I am competent at it. My whole career, I’ve needed to write code to spin up a secondary worker thread probably less than half a dozen times. So take everything I say on the subject with some skepticism. A…


As Timeless As Infinity

User: Recently I found out about a peculiar behaviour concerning division by zero in floating point numbers in C#. It does not throw an exception, as with integer division, but rather returns an “infinity”. Why is that? Eric: As I’ve often said, “why” questions are difficult for me to answer. My first attempt at an answer to…


Absence of evidence is not evidence of absence

Today, two more subtly incorrect myths about C#. As you probably know, C# requires all local variables to be explicitly assigned before they are read, but assumes that all class instance field variables are initially assigned to default values. An explanation of why that is that I sometimes hear is “the compiler can easily prove…


What’s the difference between "as" and "cast" operators?

Most people will tell you that the difference between “(Alpha) bravo” and “bravo as Alpha” is that the former throws an exception if the conversion fails, whereas the latter returns null. Though this is correct, and this is the most obvious difference, it’s not the only difference. There are pitfalls to watch out for here….


Why No Extension Properties?

I’m frequently asked “you guys added extension methods to C# 3, so why not add extension properties as well?”  Good question. First, let me talk a bit about C# 3. Clearly the big feature in C# 3 was LINQ. In a sense we had only three features in C# 3: everything necessary for LINQ –…


Why does char convert implicitly to ushort but not vice versa?

Another good question from StackOverflow. Why is there an implicit conversion from char to ushort, but only an explicit conversion from ushort to char? Why did the designers of the language believe that these asymmetrical rules were sensible rules to add to the language? Well, first off, the obvious things which would prevent either conversion…