using System;
using System.Linq;
namespace YYX.CATest
{
static class Program
{
private static void Main()
{
var names = EnumHelper.GetNames<Week>();
names.AsParallel().ForAll(Console.WriteLine);
var values = EnumHelper.GetValues<Week>();
values.AsParallel().ForAll(item => Console.WriteLine("{0}:{1}", item, (int)item));
Console.ReadKey();
}
}
public static class EnumHelper
{
public static string[] GetNames<TEnum>()
where TEnum : struct
{
return Enum.GetNames(typeof(TEnum));
}
public static TEnum[] GetValues<TEnum>()
where TEnum : struct
{
return Enum
.GetValues(typeof(TEnum))
.Cast<TEnum>()
.ToArray();
}
}
enum Week
{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
}
}