`

枚举学习

阅读更多
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
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics