日期:2014-05-17 浏览次数:20509 次
public enum days
{
sunday=0,
monday=1,
}
Type t= typeof(days);
string[] a= t.GetEnumNames();
--定义一个枚举类型
public enum Gender
{
[Description("男")]
Male = 1,
[Description("女")]
Female = 2
}
--定义一个枚举类
public static class EnumDataUtility
{
private static Dictionary<string, object> _EnumItemCollectionsStock;
static EnumDataUtility()
{
_EnumItemCollectionsStock = new Dictionary<string, object>();
}
/// <summary>
/// 获取一个枚举集合类。
/// </summary>
/// <typeparam name="TEnum"></typeparam>
/// <returns></returns>
public static EnumItemCollection<TEnum> GetEnumItemCollection<TEnum>() where TEnum : struct
{
string enumKey = typeof(TEnum).FullName;
if (!_EnumItemCollectionsStock.ContainsKey(enumKey)
------解决方案--------------------
_EnumItemCollectionsStock[enumKey] == null)
{
lock (_EnumItemCollectionsStock)
{