Discussion on:

6
Comments

Join the conversation!

Follow via:
RSS
Email Alert
0 Votes
+ -
Why not to use "Dim iEnvironment As Environment" ? Isn't better?
0 Votes
+ -
*Much* better
DPitz 26th Jan 2007
Strongly typed is always much better. Declaring iEnvironment as an integer only makes for breakable code if the Environment variable type is changed later.
0 Votes
+ -
*Much* better
DPitz 26th Jan 2007
Strongly typed is always much better. Declaring iEnvironment as an integer only makes for breakable code if the Environment variable type is changed later.
In this example, the enumeration is named Environment, which is a preexisting class in the .Net framework. Isn't it a generally accepted best practice to not create your own variables/objects using the names of key words or objects previously established within the framework?
0 Votes
+ -
Combining enumeration and .NET capabilities, I would suggest the following changes to the original code. This will produce the same result

Dim myEnv As iEnvironment

MessageBox.Show(myEnv.Production.ToString() & ": " & myEnv.Production)
MessageBox.Show(myEnv.Dev.ToString() & ": " & myEnv.Dev)
The code provided in the tip is suggested only for better understanding of enumaration and while there is certainly more than one way to get things done, this is provided as an example to functionality suggested in the tip.
Keyboard Shortcuts:
Prev
Next
Toggle
Join the conversation
Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]

Join the TechRepublic Community and join the conversation! Signing-up is free and quick, Do it now, we want to hear your opinion.