Enum.GetValues returns an array comprising all members of a particular enum type:
foreach (Enum value in Enum.GetValues (typeof (Directions))) Console.WriteLine (value);
Composite members such as LeftRight = Left | Right are included, too.
Enum.GetNames performs the same function, but returns an array of strings.
using System; [Flags] public enum Directions { Left=1, Right=2, Top=4, Bottom=8, LeftRight = Left & Right } class MainClass//from w w w . ja v a2s. c o m { public static void Main(string[] args) { foreach (Enum value in Enum.GetValues (typeof (Directions))) Console.WriteLine (value); } }