Well, I am a person who uses Enums extensively (perhaps, excessively,
if my peers are to be believed ! ) so I could probably give you
hundreds of examples of their use in my daily development. But in
order to illustrate their use, I'd have to show you the code, most of
which is proprietary and copyright. So, I'll try my best to explain...

I use Enums whenever an object can only have one or more of a definite
set of possible values and nothing else. I like to think of Enums as a
set of constants (differentiated from a single constant). They map
very well with Database constraints where a column can only have a set
of possible values. A common example used to illustrate the concept is
DaysOfWeek or SeasonsInYear or one that I like best :
TypeOfGirlfriend.

As for ArrayLists, I use them VERY sparingly, if ever. Even as far
back as VS 2002, I used custom strongly typed collections instead of
ArrayLists. As for your example, you are quite right, a string array
would have been much better. It is more than probable that the
facetious example in the book was solely to illustrate the use of
ArrayLists and not a suggestion on preferred usage. A discerning
author would in my opinion have included that disclaimer.

Hope that clarifies the concept somewhat... feel free to ask if you
need clarifications about something.

On Feb 3, 8:21 pm, john <[email protected]> wrote:
> Pardon, I wasn't clear enough..
>
> Well, here is the example from my book:
> Enum Status
>     Best = 100
>     Good = 90
>     Bad = 50
> End Enum
>
> So Status.Best can be used to mark someone's work.  It's a nice
> example, but most likely I will never use it in my place.
> All our data is loaded from database, so if I would have some marking
> system, most likely, I would have best, good and bad stored somewhere
> in database.  I think this is standard.  But since enumeration exists,
> someone is using it.  I would like to see situations where enumeration
> is the best solution.
>
> Same with ArrayList.  Here is the example from my notes:
> Dim myArrayList As New ArrayList
> myArrayList.Add("one")
> myArrayList.Add("two")
> myArrayList.Add("three")
> Dim mystring As String = CType(myArrayList.Item(0), String)
> Response.Write(mystring)
> Why not use just regular array of string in this case?  Again, in what
> situation ArrayList is considered to be the best solution?
>

Reply via email to