您是第 Web Page Tracking 位访客

水~墨~

昂首阔步,不留一点遗憾!

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

遍历枚举,enum支持中文

namespace wo_BLL
{
public class common
{

public enum error
{
错误1,
错误2


}
}
}

 

 

 

//此处使用

string ss = null;

foreach(string s in Enum.GetNames(typeof(wo_BLL.common.error)) )
{
if (string.IsNullOrEmpty(ss))
{
ss = s;
}
else
{
ss += ","+s;
}

}
MessageBox.Show("遍历枚举" + ss); return;

 

 

 

 

 

 

 

 

 

 

 

枚举作为函数参数传递

 

 

public static string IsEnumContained(string parentContext,Type a)
{

string result = "0|不存在";

if(!string.IsNullOrEmpty(parentContext))
{
foreach (string s in Enum.GetNames(a))
{
if(parentContext.IndexOf(s)!=-1)
{

result = "1|" + s + "";
break;
}

}
}


return result;
}

posted on 2012-07-23 07:11  水墨.MR.H  阅读(8806)  评论(0编辑  收藏  举报
知识共享许可协议
本博客为水墨原创,基于Creative Commons Attribution 2.5 China Mainland License发布,欢迎转载,演绎或用于商业目的,但是必须保留本文的水墨(包含链接)。如您有任何疑问或者授权方面的协商,请给我留言。