Seeing as I "researched" your code and the code on StackOverflow for my own implementations, I figure I should post this - It's a default enumerator for any Enum. Free to use, free to copy; just attribute alike :) :
public class EnumEnumerator<t> : IEnumerable<t>, IEnumerator<t>
where T : struct, IConvertible
{
private Array a;
private int index;
public EnumEnumerator()
{
var type = typeof(T);
if (!type.IsEnum) throw new ArgumentException("T is not an Enum.");
this.a = Enum.GetValues(type);
this.index = -1;
}
public IEnumerator<t> GetEnumerator()
{
return new EnumEnumerator<t>();
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return new EnumEnumerator<t>();
}
public T Current
{
get { return (T)a.GetValue(index); }
}
public void Dispose()
{
}
object System.Collections.IEnumerator.Current
{
get { return a.GetValue(index); }
}
public bool MoveNext()
{
++index; return index < a.Length;
}
public void Reset()
{
index = -1;
}
}
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.