Enumerating Enum Values

Enum.GetValues returns an array comprising all members of a particular enum type:


using System;
using System.Numerics;

enum WeekDay
{
    Monday, Tuesday, Wednesday, Thursday, Friday
}

class Sample
{
    public static void Main()
    {
        foreach (Enum value in Enum.GetValues(typeof(WeekDay)))
            Console.WriteLine(value);
    }
}

The output:


Monday
Tuesday
Wednesday
Thursday
Friday
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.