您当前的位置:首页 > ASP.NET > 文章详情

C# ASP.NET获取枚举集合

2019-06-173138人围观

例如枚举数据如下:

public enum thisEnum
{
one,
two,
three
}

获取集合的代码如下:
foreach (int type in Enum.GetValues(typeof(thisEnum)))
{
Response.Write( Enum.GetName(typeof(thisEnum), type), type.ToString()));//将会输出索引和Value
}

文章评论

热门评论
暂无评论