实现EnumHelper 类

using System;
using System.Collections.Generic;
 

public static class EnumHelper
{
    public static int GetNumberByEnum<TEnum>(TEnum e)
    {
        return Convert.ToInt32(Enum.Parse(typeof(TEnum), e.ToString()));
    }


    public static TEnum GetEnumbyNumber<TEnum>(string number)
    {

        return (TEnum)Enum.Parse(typeof(TEnum), number);

    }

}

posted @ 2011-01-22 11:12  启明星工作室  阅读(510)  评论(0编辑  收藏  举报