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
"
));
}
}
如何遍历枚举类型的对象、并获取枚举类型长度
最新推荐文章于 2017-02-22 11:10:00 发布