Switching On Types

One action I find frustrating in C# is where a particular action needs to be taken based off of the type of a particular object. Ideally I would like to solve this with a switch statement but switch statements only support constant expressions in C# so no luck there. Previously I’ve had to resort to ugly looking code like the following.

Using live mesh to synchronize favorites

I’m a huge fan of customizing my environment. As a developer my productivity is tied to access to my favorite tools, documentation, scripts, plug-ins and generally being happy with the look and feel of my computer. This runs against me using a lot of computers in my job and at home. I spend a lot of time writing scripts to keep my computers in good developer order by manually synchronizing, installing tools, etc …

Reserved Words Good For Your Sanity

Paul Vick posted a recent entry exploring the necessity, or lack there of, for having reserved words in a programming language. It’s an interesting mental exercise to go through. At the end you’ll realize that many reserved keywords aren’t needed from the perspective of the compiler. This is part of the reason C# and VB are defaulting more to contextual keywords in recent releases. What the blog post didn’t really talk about though was the programmer. From the programmer’s perspective there is one great reason for reserved words.

Equality Isn T Easy

After my recent postings on the rules of Equality, I thought it would be a good idea to post a simple example of equality. The class in question, Example, has only one field of type Integer name m_field1. Two instances of Example are equal if m_field1 has the same value. So the real equality check is just a single Integer comparison.

Iequatable Of T And Gethashcode

This is a bit of a follow up to a previous post we discussed how to properly implement equality in VB. Several users commented/asked that IEquatable(Of T) could be used in place of overriding Equals(). Since IEquatable(Of T) doesn’t define a GetHashCode() method the user didn’t need to define it and hence run into all of the problems associated with GetHashCode() usage.