Loop through enums

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Syd

    Loop through enums

    Has anybody ever figured a way to automatically loop through an enum,
    as if it were a collection? Here's an example of an enum we're using:

    public enum TaskType
    {
    TaskRange = 1,
    TaskSort = 2,
    TaskScope = 3
    }

    And what we'd like to loop through each item in a for-each loop, since
    we don't always know how many enums there are (without a human being
    checking)...

    TIA!
    Syd
  • John Saunders

    #2
    Re: Loop through enums

    "Syd" <sydney@paigeda ta.com> wrote in message
    news:2c76f997.0 308281347.4dc30 0de@posting.goo gle.com...[color=blue]
    > Has anybody ever figured a way to automatically loop through an enum,
    > as if it were a collection? Here's an example of an enum we're using:
    >
    > public enum TaskType
    > {
    > TaskRange = 1,
    > TaskSort = 2,
    > TaskScope = 3
    > }
    >
    > And what we'd like to loop through each item in a for-each loop, since
    > we don't always know how many enums there are (without a human being
    > checking)...[/color]

    Take a look at the System.Enum class. In particular, System.Enum.Get Names
    might help you out.
    --
    John Saunders
    Internet Engineer
    john.saunders@s urfcontrol.com


    Comment

    Working...