This project has moved and is read-only. For the latest updates, please go here.

EnumIterator

NuGet Package ID: CodeBits.EnumIterator

Provides an iterator that can be used to traverse through the values of an enum type.

IEnumerable<DayOfWeek> days = EnumIterator.For<DayOfWeek>();
foreach (DayOfWeek day in days)
    Console.WriteLine(day);

The iterators can also be used in a LINQ expression. For example, to get only the weekdays from the DayOfWeek enum, you could do something like this:
IEnumerable<DayOfWeek> weekdays = EnumIterator.For<DayOfWeek>().
    Skip(1).Take(5);
foreach (DayOfWeek weekday in weekdays)
    Console.WriteLine(weekday);

Last edited Jul 24, 2012 at 2:09 PM by jeevanjj, version 1

Comments

No comments yet.