公众“value__”的目的是什么?我可以在 Reflector 中针对我的枚举看到该字段吗?
我正在查看我在 Reflector 中创建的枚举,并且有一个名为“value__”的公共整数字段。
该成员的目的是什么?
文档的链接或引用就可以作为答案。
谷歌搜索很痛苦,因为“value__”返回“value”的匹配结果。
我找了将近一个小时,只找到了下面的链接。其中大多数是不同网站上的同一篇文章。它们都展示了如何通过反射访问成员,但没有一个解释成员的用途。
UPDATE
下面的最后一个链接讨论(在底部)您不能使用 value__ 作为枚举值,如下所示它是保留的,但没有说明原因。
http://www.vijaymukhi.com/documents/books/csadv/chap3。 htm
编译错误
错误 CS0076:枚举数名称“value__”被保留并且 不能使用... 仅对于枚举,它不允许我们使用保留字 value__ 因为它必须在内部使用相同的单词来跟踪 枚举。
更新 2
下面的链接是 MSDN 页面,该页面针对编译器错误,也表示“value__”被保留。但仍然不知道该成员做了什么......
http://msdn.microsoft.com/en-us/library/e3988xhs(v=vs.71).aspx
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://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)
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
Compiler Error
error CS0076: The enumerator name 'value__' is reserved and
cannot be used ...
Only for an enum does it not allow us to use the reserved word value__
as it must be using the same word internally to keep track of the
enum.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JIT 编译器需要一个值类型的定义来描述其装箱时的布局。它们中的大多数都被嵌入到 mscorlib 中,例如 System.Int32。 enum 关键字可让您创建新的值类型。因此,编译器必须在元数据中为其提供定义。这就是你正在看的。您将看到 ToString() 使用的每个枚举成员的静态字段。以及一个存储枚举值的实例字段名称 value__ 。关键点是,这只存在于枚举值的盒装版本中。
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.