惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Hacker News - Newest:
Hacker News - Newest: "LLM"
NISL@THU
NISL@THU
Know Your Adversary
Know Your Adversary
The Hacker News
The Hacker News
D
Docker
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
罗磊的独立博客
A
Arctic Wolf
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
Spread Privacy
Spread Privacy
B
Blog
A
About on SuperTechFans
L
LINUX DO - 最新话题
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
P
Proofpoint News Feed
W
WeLiveSecurity
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Google DeepMind News
Google DeepMind News
aimingoo的专栏
aimingoo的专栏
T
The Exploit Database - CXSecurity.com
美团技术团队
J
Java Code Geeks
Cloudbric
Cloudbric
雷峰网
雷峰网
Vercel News
Vercel News
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
人人都是产品经理
人人都是产品经理
Martin Fowler
Martin Fowler
G
Google Developers Blog
T
Tenable Blog
PCI Perspectives
PCI Perspectives
Engineering at Meta
Engineering at Meta
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
H
Hackread – Cybersecurity News, Data Breaches, AI and More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园_首页
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
C
Cybersecurity and Infrastructure Security Agency CISA
S
Secure Thoughts
N
News and Events Feed by Topic
GbyAI
GbyAI
S
SegmentFault 最新的问题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - changchang

SQL中的join用法(zt) 远程桌面 Web 连接 RTM、RC、CTP版本的含义(ZT) Culture Name(转) - changchang - 博客园 MPEG、RM、WMV电影文件格式转换指南(转) PDF文件相关下载 Form验证(转) .net操作文件的基本方法总结 - changchang - 博客园 JavaScript动态的为元素添加事件 dotnet下Request对象获取客户端数据的方式比较(Request.Params) - changchang - 博客园 (转载)一个大家不常用到,却很有用的页面间传值方法(Context.Handler) - changchang - 博客园 CuteEditor学习总结技巧 Javascript图片幻灯片的实现 Window下配置SVN服务器与客户端 Javascript访问html页面的控件 深入理解.net的事件与委托机制 asp.net控件本质 google map简单实现 asp.net 2.0发送和接收邮件总结
.net下枚举的用法 - changchang - 博客园
changchang · 2007-12-22 · via 博客园 - changchang

     在一次项目中需要把枚举的值添加到Combox中去,需要对枚举进行操作。经过学习总结如下,也便于以后查询:
public enum Colors { Red = 1, Green = 2, Blue = 4, Yellow = 8 };
1.根据name获得Enum的类型:
Colors mycolor = (Colors)Enum.Parse(typeof(Colors),"red",true);
(int)mycolor1=1
2.根据value获得Enum的类型:
Colors mycolor = (Colors)Enum.Parse(typeof(Colors),"1",true);
mycolor2.ToString()=Red
3.遍历枚举内容
foreach(string s in Enum.GetNames(typeof(Colors)))
{
    //to do
}
4.怎样确定一个名称或值是枚举中的一个
Enum.IsDefined(typeof(myenum),object(name or value))
5.怎样确定一个类型:  Type t = mycolor.GetType();
                   Type t1 =typeof(Colors);
                   Type t2 = Type.GetType("namespace.Colors");
补充:
Colors myOrange = (Colors)Enum.Parse(typeof(Colors), "Red, Blue,Yellow");
The myOrange value has the combined entries of [myOrange.ToString()]=13

Colors myOrange2 = (Colors)Enum.Parse(typeof(Colors), "Red, Blue");
The myOrange2 value has the combined entries of [myOrange2.ToString()]=5

另:
x.gettype和typeof的用法
1.判断某个实例是否某个类型
  c#  o is classname
  vb   typeof o is classname//必须是引用类型。typeof且必须和is联用
2.c# typeof(int)
   bv gettype(integer)
3.object类的方法
   c# o.GetType
   vb  o.GetType

付出最大努力,追求最高成就。