View Single Post
  #3 (permalink)  
Old 08-07-2007, 11:18 PM
Forrest
Posts: n/a
Quote:
Originally Posted by HelloWorld View Post
Code:
enum Status { CONTINUE, WON, LOST };
Seems useless to me, why can't you just use string instead?

Well, you can, but in a big project, you have to worry about a typo every now and then, and about case sensitivity. When you use an enum instead, it comes up in IntelliSense ( and you can add XML documentation that will be shown here ) so you can be sure you get it right every time. The refactoring engine makes it easy to change one of the status codes at any time, without getting false positives in a search and replace, but that's a side issue.

I prefer structs that give an int value in plenty of situations, mainly so you don't have to cast to int all the time.

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!
Reply With Quote