公众的“价值__”的目的是什么我可以在反射器中看到我的枚举的字段? [英] What is the purpose of the public "value__" field that I can see in Reflector against my enum?

查看:162
本文介绍了公众的“价值__”的目的是什么我可以在反射器中看到我的枚举的字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这个成员的目的是什么?

p>

一个链接或对文档的引用对于答案是正确的。



Googling是一个痛苦,因为value__返回命中为值。



我一直在搜索近一个小时,只找到下面的链接。大部分是不同网站上的文章。他们都显示如何通过反思访问会员,但是没有人解释会员是什么。



http://powershell.com/cs/forums/p/462/599.aspx



http:// tfl09。 blogspot.com/2008/12/enums-enum-values-and-powershell.html



C#函数接受枚举项并返回枚举值索引)



http://www.mail-archive.com/dotnet@discuss.develop.com/msg02431.html



更新



最后一个链接讨论(在底部),你不能使用va lue__作为枚举值,因为它是保留的,但没有说明为什么。



http://www.vijaymukhi.com/documents/books/csadv/chap3.htm



更新2



下面的链接是MSDN页面,编译器错误也称value__被保留。但是,仍然没有任何喜悦,发现会员的作用....



http://msdn.microsoft.com/en-us/library/e3988xhs(v = vs.71).aspx

解决方案

JIT编译器需要一个值类型的定义,该类型在它被装箱时描述其布局。大多数都被烧成mscorlib,像System.Int32。使用枚举关键字可以创建一个新的值类型。因此,编译器必须在元数据中为其提供定义。你正在看什么您将看到ToString()使用的每个枚举成员的静态字段。一个实例字段名称value__存储枚举值。要点是这只存在于枚举值的盒装版本中。


I am looking at an enum I created in Reflector and there is a public integer field called "value__".

What is the purpose of this member?

A link or reference to a document is fine for an answer.

Googling is a pain because "value__" is returning hits for "value".

I have been searching for nearly an hour and only found the links below. Most of these are the same article on different sites. They all show how to access the member via reflection but none of them explain what the member is for.

http://powershell.com/cs/forums/p/462/599.aspx

http://tfl09.blogspot.com/2008/12/enums-enum-values-and-powershell.html

C# function that accepts an Enum item and returns the enum value (not the index)

http://www.mail-archive.com/dotnet@discuss.develop.com/msg02431.html

UPDATE

The last link below discusses (at the bottom) that you can't use value__ as an enum value as it is reserverd but does not say why.

http://www.vijaymukhi.com/documents/books/csadv/chap3.htm

UPDATE 2

The link below is to the MSDN page that for the compiler error that also says "value__" is reserved. But still no joy an finding out what the member does....

http://msdn.microsoft.com/en-us/library/e3988xhs(v=vs.71).aspx

解决方案

The JIT compiler needs a definition of a value type that describes its layout when it gets boxed. Most of them are baked into mscorlib, like System.Int32. The enum keyword lets you create a new value type. The compiler must thus provide a definition for it in the metadata. Which is what you are looking at. You'll see static fields for each enumeration member, used by ToString(). And one instance field name value__ that stores the enumeration value. Key point is that this only exists in the boxed version of an enum value.

这篇关于公众的“价值__”的目的是什么我可以在反射器中看到我的枚举的字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆