您的位置:首页 > 其它

[导入](论坛答疑点滴)遍历枚举

2007-02-05 22:20 253 查看
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"));
}
}

lovecherry 2006-01-19 11:26 发表评论
文章来源:http://www.cnblogs.com/lovecherry/archive/2006/01/19/320151.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: