Thursday, February 16, 2006


Tutorial : enum lacks type-safety

enum provides convenience and improved productivity. The possible values get listed in IntelliSense, so it's easy to select the one you want during programming. If your method takes an enum as a parameter, the users of your API will typically select a value from the list presented by IntelliSense
But unfortunately , what happen when you pass an invalid parameter ?
Do not assume that the value of an enum received as a method parameter is within range. Check to verify it. This will make your code more robust. Program defensively.

Comments: Post a Comment

Links to this post:

Create a Link

<< Home

This page is powered by Blogger. Isn't yours?