View Single Post
  #10 (permalink)  
Old 08-15-2007, 01:25 PM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
generally you will use Enum in place of "Magic Numbers" or Constants.

For example if you had 3 statuses for a user and had them three statuses in the database like:
ID=>1 & Name=>Admin
ID=>2 & Name=>SuperUser
ID=>3 & Name=>User

You would hit the DB, and get back 1 (which is an admin). Now you would set User.UserType (Usertype is your enum) = Admin (Not 1). Then anywhere in your application you can just do:

If User.UserType = (Then intellisense will popup and tell you your options) - no need to remember what it is and it's reliable because it now knows what it can be and you can just select the options from a list.
Reply With Quote