protected void Page_Load(object sender, EventArgs e)
{
Type weekdays = typeof(Days);
Type boiling = typeof(BoilingPoints);
foreach (string str in Enum.GetNames(weekdays))
{
Response.Write("The days of the week, and their corresponding values in the Days Enum are: <span style=\"color:#F00;\">" + str + "</span><br>");
}
foreach (int bo in Enum.GetValues(boiling))
{
Response.Write(bo + "<br>");
}
}
protected enum Days
{
Saturday,
Sunday,
Monday,
Tuesday,
Wedenesday,
Thursday,
Friday
}
protected enum BoilingPoints
{
Celuis = 100,
Fahrenheit = 212
}
枚举学习
最新推荐文章于 2025-10-13 19:47:50 发布
本文展示了一个使用C#编写的简单示例程序,该程序定义了两个枚举类型:Days和BoilingPoints,并通过foreach循环遍历枚举值并显示在网页上。Days枚举包含了星期几的名称,而BoilingPoints则包含了水在不同单位下的沸点。
362

被折叠的 条评论
为什么被折叠?



