遍历枚举类型
using System;
public class EnumTest {
enum Days { Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday };
public static void Main() {
Type weekdays = typeof(Days);
Console.WriteLine("The days of the week, and their corresponding values in the Days Enum are:");
foreach ( string s in Enum.GetNames(weekdays) )
Console.WriteLine( "{0,-11}= {1}", s, Enum.Format( weekdays, Enum.Parse(weekdays, s), "d"));
}
}
本文来自博客园,作者:NLazyo,转载请注明原文链接:https://www.cnblogs.com/bile/archive/2012/10/24/2737383.html