![[转][C#]枚举的遍历Enum [转][C#]枚举的遍历Enum](https://image.shishitao.com:8440/aHR0cHM6Ly9ia3FzaW1nLmlrYWZhbi5jb20vdXBsb2FkL2NoYXRncHQtcy5wbmc%2FIQ%3D%3D.png?!?w=700&webp=1)
// 加载所有颜色
//foreach (Color item in Enum.GetValues(typeof(Color)))
foreach (var item in typeof(Color).GetMembers())
{
if (item.MemberType == MemberTypes.Property && Color.FromName(item.Name).IsKnownColor == true)//只取属性且为属性中的已知Color,剔除byte属性以及一些布尔属性等(A B G R IsKnownColor Name等)
{
Debug.WriteLine(item.Name);
}
}