当前位置:首页>网络学院>程序开发>c#教程>文章内容

遍历枚举的所有值实现源代码

[ 来源:http://www.it55.com | 作者: | 时间:2007-10-16 | 收藏 | 推荐 ] 【

using System;

namespace PSP
{
    class GetEnumValues
    {
        public static void Main()
        {
            Type Sexs = typeof(SexKind);
            Console.WriteLine("The  kinds  of  the  Sex:");
            foreach (string s in Enum.GetNames(Sexs))
            {
                Console.WriteLine(s);
            }
        }
    }

    enum SexKind
    {
        Male,
        Female
    }

(编辑:IT资讯之家 www.it55.com

返回顶部
 

网友评论

[以下评论为网友观点,不代表本站。请自觉遵守互联网相关政策法规,所有连带责任均有评论者自负。]
[不超过250字]