DayOfWeek[] enumArray = new DayOfWeek[] {
DayOfWeek.Monday, DayOfWeek.Wednesday };
//Convert enum to int array
int[] result = Array.ConvertAll<DayOfWeek, int>(enumArray,
delegate(DayOfWeek value) { return (int)value; });
//with C# 3.0, a lambda:
int[] result2 = Array.ConvertAll(enumArray, value => (int) value);
//with C# 3.0 using Cast
int[] result3 = enumArray.Cast<int>().ToArray();
Wednesday, April 29, 2009
Convert an Enum Array into an Interger Array
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment