Anders Hejlsberg talks about C# 4.0

Channel 9 has posted a great talk by Anders Hejlsberg, the original author of Turbo Pascal, the chief architect of Delphi, and the lead architect of C#.

History lesson: Anders was lured away from Borland by Microsoft with a hefty offer of a $1.5 million signing bonus, a base salary of up to $200,000, and options to buy 75,000 shares of Microsoft stock.

Looks like it was worth it, as each C# release has added many interesting and powerful features, while maintaining a fine balance between complexity and simplicity.

Inconsistencies in the .NET Enum class

During a recent project of mine, I had to do a lot of enum manipulation using the .NET Enum class and I have to say I wasn’t impressed. Besides the shortcoming of it not being a generic class (and thus not being especially type-safe), Enum also has some strange inconsistencies in terms of how it handles matched integral types.

Read more »

How to put spaces in your NHibernate enums

NHibernate lets you map C# enums to database columns. This can be quite convenient in cases where you have a database column for something like gender. To map them, you follow the procedure outlined here.

That works all fine and dandy, as long as the strings you want to store in the database are valid C# identifiers.

Read more »

Joshua Bloch’s Builder Pattern in C#

Having spent a lot of time programming in Java over the last two years, I’ve made heavy use of Joshua Bloch’s Java Builder pattern (also Effective Java Item 2).

Recently, I’ve started a fairly large project in C# 3.0. As it happens, there came a point where I wanted to use a pattern similar to Bloch’s Builder. However, as anyone who tries to use this pattern in C# will quickly find out, Bloch’s Builder doesn’t translate perfectly to C#.

Read more »